I spent a few hours getting a compiler toolchain set up for building #c64
programs. I tried #calypsi and #llvm, and so far llvm-mos generates much more compact code. I also tried using the rustc, compiling to llvm intermediate, then compiling that to 6502. The resulting binary didn’t quite work, so I’m going to build a custom rustc and try that. The code it generated was highly optimized. Using the same backend, #rust generated larger code than C, but it was aggressively optimized for speed instead of size.
For example, when copying sprite data from a const array it generated a lot of STA ops using the same values stored in registers, since the data was highly repetitive. The same code in C copied a const array using a loop. If I had to guess, the Rust code was much faster, and might be a couple bytes longer. For the entire program, the same code written in C was a couple hundred bytes smaller (like 500 vs 700 or so). Once it actually works, I’m going to do a deeper dive on the generated code.