3 ms·
"Accessing any address [on 6502] higher than the zero page (0x0 to 0xFF) causes a performance penalty." I never thought of it that way, but that's true. Howeve
by classichasclass 8y ago
"Accessing any address [on 6502] higher than the zero page (0x0 to 0xFF) causes a performance penalty."
I never thought of it that way, but that's true. However, he didn't mention the biggest issue with C on the 6502, i.e., the extremely constrained 256-byte hardware stack. To do anything practical requires some sort of software-maintained stack to have stack frames of any decent size or quantity (in parallel, or replacing the use of the hardware stack completely). "Downright hostile to C compilers," indeed.
- sehugg 8y agoIt'd be nice if compilers were smarter about using the stack (looking at you, cc65) -- you could have "big" stack frames and little stack frames, pass variables in registers, push values as 8-bit instead of upcast to 16-bit, convert locals to static, etc. I'm going to take a look at yet another alternative 6502 language called C02 now: https://github.com/RevCurtisP/C02 https://github.com/RevCurtisP/C02
- classichasclass 8y agoThe big problem with passing in registers is you only have three, and only one of them can do most of the work. Maybe zero page could help there for a fast call convention, but either way you're probably going to have to spill to memory, which fortunately is not a big deal on the 65xx.