3 ms·
I wonder if you can write fast C for the 6502, though, but you'll have to constrain your use of the language considerably?
by TazeTSchnitzel 7y ago
I wonder if you can write fast C for the 6502, though, but you'll have to constrain your use of the language considerably?
- spc476 7y agoThe 6502 is a very constrained CPU. It only has 6 registers, only one of which (PC) is 16 bits. The stack is fixed at addresses 0x0100 to 0x01FF, and the two index registers are 8-bits in size. So is the accumulator and the stack register (hence the fixed address for the system stack) and no stack-based addressing modes. You'll have a severe penalty in doing any 16-bit arithmetic. There is no general multiply or divide instructions. I think the architecture is about as hostile to C as you can get and still be popular.
- bsder 7y agoThe main problem is that most compilers really need lots of registers to optimize well. Without lots of registers, you're constantly spilling to memory and that makes things slow. If you program in assembly, you have visceral knowledge of when you overrun you registers and you will restructure the entire architecture of your program to avoid that.