What is it?MP-Assembler is an assembler to be used on the PC to assemble source code for the 6502, its compatible successors and the Z80. MP stands for "Multi-Processor": it can assemble 6502, 65C02, 65816, 6800, 6809 and Z80 opcode. The special feature of this assembler is that you can mix all opcodes in the same file. This can come in handy when assembling programs for the C128 (6502 and Z80) and the MMF-9000 (6502 and 6809).
The storyToday a lot of assemblers exist for the 6502, Z80 etc. and each claims to be better than all the other ones. But when I started to write this one in 1988, there wasn't one available as free/shareware (AFIAK) on the PC. There were some available for the C64 but here I encountered a problem: I wasn't able to handle large source codes; the C64 lacked the needed memory. At that time I already was thinking about replacing the drive of the 1541 with an hard disk and thus a big change of the original system ROM was needed. Much more memory and a bigger screen made me to decide to use a PC instead.
I don't think my assembler is better the other ones but it has one major advantage: you get the source code with it! So if you don't like or miss certain features, you simply change them or add ones of your own!
My assembler is a multi-pass assembler. There exist two- and even one-pass assemblers but they are limited or IMHO they use one or another trick to conceal the fact that you need at least three passes to determine all labels.
Using the assemblerUsage: MP-ASSEM /Ffilename
/Ffilename = the extensions ".A65" or ".ASM" may be omited
The assembler filesThe only thing the assembler asks from you is a begin and an end mark (.ba and .en). For the rest you're absolutely free to write it in the way you want. You can define more then one begin address but be warned: it is your own responsibility to take care not to overwrite previous assembled code!
To help you to streamline your application you have a lot of compiler directives at your disposal:
.al = pre-defined labels that can be ALtered .ap Filename = APpend a file to be assembled as well .ba $xxxx = Begin Address of the code or data. More then one .ba may be used. .by [$]aa, [$]bb, [$]cc..... .by label1, label2..... = define a range of BYtes. You can use fixed values as well as labels. .co This is comment = COmment to be displayed on the screen during the last pass .ei = End If: end of conditional programming .el = ELse: part of conditional programming .en = ENd of file. All text, code or data behind this mark will be ignored. .eq OwnLabel1 = $xx .eq OwnLabel2 = $xxxx .eq OwnLabel3 = OwnLabel2 + 1 = EQuals, define your own label. Values can NOT be changed. .fi Filename = use a binary FIle as base for your own binary. Can be used to write patches over original binaries. .fb [$]xx, [$]yy .fb "c", [$]yy .fb label, [$]yy = Fill Byte: fill a range of length [$]yy with the same byte. A character, a fixed value or a label can be used as input. .fd [$]xxxxxxxx, [$]yy .fd "c", [$]yy .fd label, [$]yy = Fill Doubleword. .fw [$]xxxx, [$]yy .fw "c", [$]yy .fw label, [$]yy = Fill Word. .if label = IF: start of conditional programming. .ma Name = define a MAcro. .me = Macro End .rb $aaaa = Re-address Begin. Following code will be assembled as if it was situated at address $aaaa. .re = Re-address End .ta = translate given text to ASCII (default) .tp = translate given text to PETSCII .tx "This is 'TEXT'" .tx 'This is "TEXT"' = TeXt .tw "This is 'TEXT'" = TeXt, first char+$80 (for Commodore) .ty "This is 'TEXT'" = TeXt, last char+$80 (for Commodore) .tz "This is 'TEXT'" = TeXt, first and last char+$80 (for Commodore) .uu filename = Use external Unit as source for the used macros .wo $aaaa, $bbbb, $cccc..... .wo label1, label2..... = define a range of WOrds. ; Here you can place comments = remark /* here you can place several lines of comment */ = speaks for itself IMHOI'm working on a Pascal Compiler that uses this assembler to generate the executables. This means implementing features and directives that are not mentioned yet in this document.
The produced files
.BIN = binary to be used for programming EPROMs etc. .CRF = text file with cross references .LST = text file with complete listing of statements and resulting code .NEW = text file, same as ASM file but after all macro's etc. have been prosessed .PRG = BIN file plus two extra address bytes, needed for Commodore .RES = text file, shows all calculated ranges
ExamplesRemark: most browsers aren't familiar with the ASM extension and will ask you whether to open or save it. So I saved the examples with the TXT extension so you can view them on your browser.
If you download these examples, you can assemble them as they are using "MP-ASM /Fexample.TXT" or rename them to ASM and using "MP-ASM /Fexample".
C000.asm is a very small but working code. It writes the character 'A' in the top-left corner of your C64 screen. ".ba $C000" means that the program starts at $C000 / 49152. The PRG should be loaded on a C64 with LOAD "C000",8,1. SYS 49152 will start the program.
Warning: be aware of the space in front of the opcodes! If there isn't any form of white space in front of an opcode, the assembler will treat it as a label. And as it won't recognise the operand as opcode, the assembler will end with an error.
C001.asm will display the alphabet on the screen. Notice the place of label L1. Also notice that, although it is quite small, the program is hardly readable.
C002.asm is the same program but made more readable. The most important difference are the lines with comment. How small your program is, comment it! If it isn't for your self, do it for others.
test6580.asm is a test file used by me to test almost all features of the assembler. It also explains the use of most directives. If you have questions, just drop me an email.
The futureFor the moment I have no major changes in mind. I dropped implementing 8088 code. The CBMs that can run 8088 code, the 6x0 7x0 series, can only run it from separate files. And as there are more then enough 8088 assemblers available for the PC, it makes no sense to me to invent the wheel again.
The source code.The source code is freeware, just drop me a line and it will be sent to you.
You can email me here.