4 ms·
> There's something magical about writing code in C for these old 8-bit and 16-bit CPUs. Eh, I'm not sure I would agree, about the 6502 specifically. It's a p
by 0815test 7y ago
> There's something magical about writing code in C for these old 8-bit and 16-bit CPUs.
Eh, I'm not sure I would agree, about the 6502 specifically. It's a pretty bad match to C since e.g. it doesn't have a relocatable stack and common pointer-based operations are quite clunky despite the provision for several address modes. FORTRAN-like languages really do match quite a bit better. In a different way, so does FORTH.
Also, plenty of people did have fun writing assembly code for the MC68k, which is a 32-bit CISC architecture. It's really only x86 (and maybe VAX) that tends to be a bit clunkier.
- klodolph 7y agoHaving written 6502 assembly but not targeted 6502 with C, I tentatively agree, but if you can fit your program in a 256 byte stack, things should be... mostly fine? Except for the fact that you want to do pointer indirections through the zero page. Clunky! Personally if I'm going to have fun writing assembly for a project like this, I'm not too picky about the particular architecture.
- ddingus 7y agoIt is clunky, but the instructions are fast. Always thought that was an interesting trade off.
- klodolph 7y agoThey’re fast, but you’re not using them well if you’re writing C, because the compiler is not good at putting things like local variables, function arguments, or globals in the zero page. It’s only 256 bytes and you can’t easily share. So for 6502 I would rather not be writing C.
- ddingus 7y agoNor would I. Check out PLASMA. That is being used to develop the game lawless legends. It's pretty damn impressive.
- sehugg 7y agoThe dominant C compiler (CC65) has a separate stack for parameters and local variables, and keeps SP as a pointer in zero-page. This is a nice general approach that allows for deep stacks, recursion, and lots of locals, but isn't very efficient. Newer experimental 6502 languages either forbid recursion (cowgol) or limit parameters passed to functions (C02), but I can see a language using a hybrid of stack and zero page to keep locals and parameters. The drawback of high-level programming on the 6502 is you are always looking for ways to make it better... :)