Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

From what I understand, LLVM-MOS treats large parts of the zero page as virtual ("imaginary") registers, so you have no shortage of that (https://llvm-mos.org/wiki/Imaginary_registers). Then, sufficiently advanced compiler technology improves the stack situation (https://llvm-mos.org/wiki/C_calling_convention).


6502 assembly has the distinct advantage of having special page-0 instructions for reading/writing from memory, including, if I recall correctly, the ability to take a 2-byte sequence and treat it as a 16-bit value (or was that in the AppleSoft ROM?)


The main way to do pointer indirection (without self-modifying code) is to use the zeropage-specific indirect addressing modes, which use a 2-byte address stored in zero page as a pointer to a byte in memory. (And on the original 6502, the only available addressing modes for this forced you to use the X or Y register as an index, so you had to set it to 0 first!)


You can treat 2 bytes (not just in the zero page, though) as indirect jump addresses, yes.

Doing something like "JMP ($2345)" will jump to whatever $2345/$2346 is pointing to.


It's a little amazing how much 6502 assembler sticks with me 35 years later.

But only a little. I didn't have the money to buy an assembler or the skill to write one so I would write out my programs in long-hand on graph paper and hand-assemble them before entering hex codes manually. While not the most efficient process, it did do a good job of encoding things into long-term memory.


Haha, yes, I can relate. I didn't do any 6502 coding for ~25 years and it mostly just stuck around. Apparently it's like riding a bike.

In the meantime I've forgotten most of the 68000 and z80 instruction sets.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: