News for hackers. Stuff that matters.
Re:Rust on the MOS 6502: Beyond Fibonacci by dhosek on Tuesday September 21, 2021 @09:27AM (#28604806)
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?)
Re:Rust on the MOS 6502: Beyond Fibonacci by retrac on Tuesday September 21, 2021 @12:00PM (#28606425)
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!)
Re:Rust on the MOS 6502: Beyond Fibonacci by royjacobs on Tuesday September 21, 2021 @09:29AM (#28604826)
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.

Re:Rust on the MOS 6502: Beyond Fibonacci by dhosek on Tuesday September 21, 2021 @09:31AM (#28604855)
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.

Re:Rust on the MOS 6502: Beyond Fibonacci by royjacobs on Tuesday September 21, 2021 @09:41AM (#28604930)
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.