Converter from cc65 asm to beebasm

discuss pc<>acorn file transfer issues and the use of other utils
Post Reply
User avatar
tricky
Posts: 7694
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Converter from cc65 asm to beebasm

Post by tricky »

Continuing my search for a way to convert the Missile Command disassembly to beebasm, I have decided to use 6502Bench to export for cc65 and then convert that to beebasm.
It doesn't export the addresses, and I haven't included an assembler to find what addresses things should be but so far, I have only found one thing that throws things off. If the cc65 asm uses an absolute addressing instruction where the same could have been done with a zero page addressing mode, beebasm will generate one byte less. Fortunately, cc65 has an expression/label/something prefix of a: to say 16 bit address, so when I see this I add a NOP after the instruction with a comment to make them easy to find later.
I have used this and the only differences is where this has happened and the opcode has been changed to ZP addressing and the &00 byte replaced with &EA (NIOP).
cc652beebasm.zip
(5.28 KiB) Downloaded 39 times
Read the code at your own risk!
Mostly basic C++ with one auto and a few for(:)s.
Zip includes a VS2019 project and solution.

Local labels mean that scopes have to be added to the code, but making them from the nearest global variables before and after seems to work.
There are a few other tricky bits, like variables and what there scopes are. These sometimes require the same variable to be declared locally and globally, but beebasm seems happy. They also need redefining when they get redefined!
.faraddr is a three byte value, which I split into three separate bytes in an EQUB.
.setcpu just generates a comment of whatever the string was.
.asciiz should be a C style NULL terminated string, but this isn't used and I haven't supported it.
I may have missed some other things, as I have never used cc65 assembler, but they should hopefully be trivial to add if anyone ever wants to.
Post Reply

Return to “software & utilities for the pc, mac or unix”