Page 1 of 1

call for testers - 6502 assembler

Posted: Tue Sep 20, 2011 7:04 pm
by duran
Greetings osdevers,

I'm not certain if this should go in GP, but it fits better than the OS announcements board. I've written a small, simple, 6502 assembler in Perl for my own amusement, and to learn a little about the process of assembling machine code. I targeted the 6502 as a simple real world cpu, but it's merely a jumping off point to explore SPARC or possibly VAX at a later date.

I've reached a point where it can spit out a raw binary image of the assembled code. It reads the source code from stdin, producing a listing and symbol table on stdout, and dumping the assembled binary to a file named a.out. I know there are still some bugs, but I also know I'm no expert on the 6502, so I'm putting this out there for anyone who wants to test it and give some feedback so I can get it to a fully functional state.

All standard 6502 instructions and addressing modes are recognised. I neglected to add language support for BCD data - this will come later on. I've tried to adhere to the Commodore 64 style syntax for addressing modes where possible:
  • Immediate values are prefaced with a #, they can be either decimal or hex (hex should be prefaced with $)
    labels are defined using the format /[a-zA-Z_][a-zA-Z_0-9]?/.
    labels declaring a value are marked with an =. labels declaring a jump or subroutine beginning are followed by a :
    raw byte and word declarations can be made using the .byte and .word directives, followed with a comma separated list of hex values
The addressing mode selection code is based on the syntax and value of the operands specified for each instruction. all memory addresses that are below $100 are automatically treated as zero-page addresses, even if explicitly stated by a full word value in source. This is not by intentional design (At least, I didn't realise it at the time), and will probably change at a later date.

Source is hosted on github (https://github.com/duranain/6502asm/tree/volatile). the volatile branch is active development. I apologise in advance for the present state of the code. It has fallen into some neglect as I have been hacking away, and is in need of some cleanup.

Feedback is greatly appreciated.