f65 - "fake 6502" porting layer This is a set of C macros that implements most of the 6502 assembly language instructions, plus a perl script to convert 6502 assembly source to C code that calls the macros. You can use it to assist in porting 6502 assembly routines to C, using either the original asm source, or a disassembly created with da65. What's implemented: 64K of memory. The A/X/Y/S registers. The carry, zero, and negative flags. Most arithmetic and logic instructions. The stack. Conditional branches and absolute jumps are implemented as C goto's. JSR is implemented as a real C function call, and RTS is a real C return. Labels in the assembly source become C labels (aka goto targets). Equates in the asm source become C variables. What's not implemented: The D flag, and decimal mode in general. The V flag, and branches based on it. The I and B flags. Interrupts and the RTI instruction. The Program Counter (though branches, JMP, JSR, and RTS are implemented without it). ROM routines (including I/O). Indirect JMP. The "CPU bug" that causes e.g. 'LDA ($FF),y' to take its high byte from $00 rather than $100. (zeropage, x) addressing mode. I wrote this specifically to port the decompression algorithm from UnAlf 1.4. Instructions not used by UnAlf probably aren't implemented, or if they are, they're untested. The perl script doesn't magically convert a whole 6502 program to C source. You'll have to figure out which parts of the 6502 program are subroutines, and put them in their own C functions. Any data (.byte, .word, etc) won't be in the C program. Anything that does I/O must be rewritten in C.