Ruud's Commodore Site Home  Email

MP-assembler




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". The special feature of this assembler is that you can mix 6502- and Z80-opcodes in the same file. This can come in handy when assembling programs for the C128. The MMF-9000 also contains a 6809. For this reason I want to enable this program to handle 6809 code as well in the future.


The story

Today a lot of assemblers exist for the 6502 and Z80 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). I don't think my one is better 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 assembler

Usage: MP-ASSEM /Ffilename [/L] [/R$aaaa-$bbbb]
/L             = save labels in filename.LBL
/R=$aaaa-$bbbb = range of bytes which should be saved. Only one range
                 can be supplied.

The assembler files

The 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:
.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 conditional programming
.el             = ELse 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 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 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 IMHO
I'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 future

The only feature I want to implement is that I want to be able to compile 6809 (CBM9000) and/or 8088 (CBM730) code.


The source code.






Having questions or comment? You want more Info?
You can email me here.