Assembling code by hand is possible, but for any program of non-trivial size, cross-compilation is the way to go, even for 8-bit processors like the 6809. When working with my 6809 single board computer I went looking for a suitable cross-assembler. My requirements were to support the 6809, run on Linux, and be freely available. I came across three suitable programs, which I'll briefly describe here.
AS9 Assembler
Home page: http://home.hccnet.nl/a.w.m.van.der.horst/m6809.htmlDocumentation: http://home.hccnet.nl/a.w.m.van.der.horst/as11v2.pdf
This code is apparently derived from the original and official Motorola cross-assembler circa 1981. Written in very old pre-ANSI standard C, it was modified by a number of people over the years, and this version was last modified Albert van der Horst in 2004 to compile under Linux. I had no trouble building it under Ubuntu Linux.
As the official Motorola assembler, it follows the Motorola documentation. It seems pretty comprehensive, and supports the 6800, 6809, 68HC11, and some other chips in the 68xx series.
I have used this as my primary cross-assembler to develop or port the 6809 code I've been working on. The S-record files it generates are happily accepted by the ASSIST09 monitor's Load command.
Here is a sample output listing:
0005 7000 ORG $7000 ; Start address
0006
0007 7000 86 12 START: LDA #$12
0008 7002 c6 34 LDB #$34
0009 7004 8e 56 78 LDX #$5678
0010 7007 1e 89 EXG A,B
0011 7009 12 NOP
0012 700a 12 NOP
0013 700b 39 RTS
The only quirk I encountered is a known issue where it can produce invalid warnings about comments. I worked around this when needed by disabling warnings with a command line option.
ASM6809 Assembler
Home page: https://www.6809.org.uk/asm6809Documentation: https://www.6809.org.uk/asm6809/doc/asm6809.shtml
This is a portable cross assembler targeting the Motorola 6809 and Hitachi 6309 written by Ciaran Anscomb. It features arbitrarily complex expressions (with most C-style operators available), forward references, macro expansion and conditional assembly. Output formats are: raw binary, DragonDOS binary, Color Computer RS-DOS or "DECB" binary, Motorola S record, and Intel HEX.
Written in C, it is licensed under the GPL and is actively being maintained with the latest version being 2.11 released on 2018-07-27.
I downloaded the source and was able to build it with no problems simply by running the configure script, make, and sudo make install.
Trying it on my 6809 disassembler program (about 2000 lines of code), the only issues I encountered were that it didn't accept labels with a colon at the end and it didn't like one symbol I used that started with a dot. After making appropriate changes, the code built fine. It even warns that some long branches fit in eight bits and could have used short branches, so I modified them and made the code a little smaller. I did notice that it generated slightly different code than the as9 assembler had, where it picked a different (more efficient) indexed addressing mode that could use a 5-bit displacement.
Here is a sample listing:
7000 ORG $7000 ; Start address
7000 8612 START LDA #$12
7002 C634 LDB #$34
7004 8E5678 LDX #$5678
7007 1E89 EXG A,B
7009 12 NOP
700A 12 NOP
700B 39 RTS
It generated a Motorola S record (RUN) file, but the ASSIST09 firmware did not like to load it. Investigation showed that it was producing S record files with invalid checksums. I made a code fix to the source for this. It also doesn't produce the S9 record at the end of the file that ASSIST09 wants to see, unless you have an END directory specifying that start address.
LWTOOLS
Home page: http://lwtools.projects.l-w.ca/Documentation: http://lwtools.projects.l-w.ca/manual/manual.html
LWTOOLS is a set of cross-development tools for the Motorola 6809 and Hitachi 6309 microprocessors. It supports a number of output formats including raw binary, Motorola S record, Color Computer binaries, and a proprietary object file format that supports linking.
It is implemented in C and is actively maintained. I used version 4.16 that was released in December 2018.
It supports a number of platforms. I was able to build it with no issues on Ubuntu Linux. It installs a number of tools including lwasm, lwlink, lwar, and lwobjdump.
Here is a sample output listing:
( ex1.asm):00005 ORG $7000 ; Start address
( ex1.asm):00006
7000 8612 ( ex1.asm):00007 START LDA #$12
7002 C634 ( ex1.asm):00008 LDB #$34
7004 8E5678 ( ex1.asm):00009 LDX #$5678
7007 1E89 ( ex1.asm):00010 EXG A,B
7009 12 ( ex1.asm):00011 NOP
700A 12 ( ex1.asm):00012 NOP
700B 39 ( ex1.asm):00013 RTS
I only tried the assembler, using my disassembler program again. It didn't like items in FCB directives to be separated by any white space, only commas. It also didn't a like symbol starting with "." Other than that it assembled it fine, and generated a S record file which I successfully loaded and ran on the single board computer.
For advanced development work where you might want to assemble multiple files and link them, this looks like a good choice for a toolset. A 6809-based C compiler I have tried, CMOC, uses it as it's cross-assembler.
No comments:
Post a Comment