A project to port LLVM to the MOS 6502
github.com
github.com
When writing 6502 assembly by hand, you usually just create a few global variables as “temporaries” for storage, parameter passing, etc. and you write your code carefully to make sure any subroutines you call don’t try to use a temporary you’re already using, or anything like that. Obviously, this doesn’t look anything like idiomatic C.
For this reason, I’m really interested in seeing what kind of code this generates and how it performs, especially compared to the dominant 6502 compiler cc65 (https://cc65.github.io/).
If you want more than 256 bytes of local variables you will have to setup more offset copies of the stack pointer in the zero page first.
Also most variables can be stored in the zeropage as caller-saved pseudo-registers and only spilled on the stack as needed.
If you don't have threads or recursion then assigning fixed addresses is even better.
It may however overall be much more space-efficient to implement a bytecode emulator for a proper 32/64-bit instruction set instead of trying to generate 6502 code.