A long time ago, I've made some games for the Commodore Amiga. All done in 68000 assembly (So I still have the sources)
I want to port these games to modern platforms, and instead of hosting an emulator, I thought of converting the Assembly to C, and adding an SDL layer.
Any thoughts on how to tackle the 68000 -> C conversion part? (Not manually but automatically. As in a transpiler)
I was thinking of just creating a bunch of variables with similar names as the registers and then converting things like this:
MOVE.l #23, d7
into
MOVEL(23, d7);
The only thing I'm not sure how it would work is branches and subroutines. I think I could get it working with a very big switch statement, and having any label I could potentially jump to being a case statement.
Any thoughts? Any prior art I could draw inspiration from?
BSR
/JSR
and translate the jumps into C function calls? For other types of branches it seems to me likegoto
would be easier to work with than switch-cases. – Melvinmelvinagoto
+ C labels should be totally fine. A few manual fixes total for the whole program might be required for the occasional jump into another function, but that's fine, you're already planning to spend some time porting the graphics output. The decompiler you cobble together does not need to be 100% automatic, as long as problems turn into won't-compile errors in C, rather than subtle gotchas. Labels within functions andif() goto
will make your C look very much like asm, unlike a giantswitch
. – Velitessp
to not be part of the C program's state, with all stack ops turned into local variable allocation, or alloca or C99 VLAs for variable-size subtractions. But C can't directly express the pattern of pushing items on the stack one at a time, then popping them off in reverse order. (i.e. using the call-stack as a stack data structure, which is easy in asm.) – Velites