Can you write for the Commodore 64 in Rust? Why yes, yes you can!
Using llvm-mos, rust-mos, a lot of time compiling compilers and support from Mariusz (the rust-mos author), I was finally able to program like it was 1982...
I was inspired by Jason Turner's talk where he did this using C++, and I wondered--hey, that was my first computer back in the day... Can I do that with my favorite language?
First test was to see how well rustc and llvm would optimize an idiomatically written 120-line trivial Rust program (which reads the joystick fire button status to set screen border color) to x86 assembly. Turns out the compilers pack it down to three instructions. Yep. 3. See for yourself! (remove the -C opt-level=3 to remove optimizations).
That is just bananas! Modern compilers are amaaazing.
So I wrestled for several days compiling compilers that would target the C-64's MOS-6510 (same instruction set as MOS-6502 also used by Atari, Apple and many, many others back in the day.) It's still a work in progress, but it is working pretty well!
use ufmt_stdio::{println, ufmt};
#[start]
pub fn main(_argc: isize, _argv: *const *const u8) -> isize {
println!("hELLO, {}-BIT C-64 WORLD, FROM rUST!", size_of::<*const ()>() * u8::BITS);
ReturnCode::Ok.into()
}
compiles down to 232 bytes in release mode. (Yes, bytes). The code fits on a single block (256 bytes) of a C-64 floppy disk. And runs beautifully. (Note the inversion of case on this pre-ASCII (!) computer)... :)