4 ms·
> If you want to modify anything else in the 16-bit address space, you first need to write a 16-bit pointer to the Zero Page containing the location you want, t
by rbanffy 2y ago
> If you want to modify anything else in the 16-bit address space, you first need to write a 16-bit pointer to the Zero Page containing the location you want, then use an instruction which references that pointer.
This is so completely wrong I question the person's ability to understand what's happening in the emulator.
Also, that LDA instruction reads the 2-byte pointer from the memory location, adds Y, and loads the accumulator from the resulting memory position. IIRC, the address + Y can't cross a page - Y is added to the least significant byte without a carry to the MSB.
> and the program is stored as some sort of bytecode
We call it "tokenized". Most BASIC interpreters did that to save space and to speed parsing the code (it makes zero sense to store the bytes of P, R, I, N, and T when you can store a single token for "PRINT".
- toast0 2y ago> This is so completely wrong I question the person's ability to understand what's happening in the emulator. I'd argue that it's not completely wrong in the context of a BASIC program; other addressing modes exist, but I don't think the BASIC interpreter will use self-modifying code to make LDA absolute work. > IIRC, the address + Y can't cross a page - Y is added to the least significant byte without a carry to the MSB. If wikipedia is accurate, the address + Y can cross a page boundary, but it will take an extra cycle --- the processor will read the address + Y % 256 first, and then read address + Y on the next cycle (on a 65C02 the discarded read address will be different). But if you JMP ($12FF), it will read the address from 12FF and 1200 on an 6502 and a 12FF and 1300 on a 65C02 --- that's probably what you're thinking of.
- rbanffy 2y agoThanks. It’s been 40+ years since I last programmed in 6502 assembly. I am rusty.
- anonymousiam 2y agoYeah. I got as far as the zero-page description and stopped reading. The 6502 was the first microprocessor I learned (on the KIM-1) in 1979. All that zero page addressing offers is a faster way to access memory, because when using zero-page addressing modes, you only need one octet for the address instead of two. When using them on a 1MHz CPU with no cache, you've just saved many microseconds because you didn't need to fetch the high order address octet from program memory! On the 6502, you can absolutely access all 64K of memory space with an LDA instruction. The other weird thing about the 6502 is "page one", which is always the stack, and is limited in size to 256 bytes. The 256 byte limit can put a damper on your plans for doing recursive code, or even just placing lots of data on the stack. I've done lots of embedded over the years, and the only other processor I've developed on that has something similar to the 6502 "zero page" memory was the Intel 8051, with it's "direct" and "indirect" memory access modes for the first 128 bytes of volatile memory (data, idata, bdata, xdata, pdata). What a PITA that can be!
- bluGill 2y ago> On the 6502, you can absolutely access all 64K of memory space with an LDA instruction. There are two LDA instructions (maybe more, I too am about 40 years rusty). One loads from page 0 only and thus saves the time by only needing to read one byte of address, and the other reads two bytes of addresses and can read from all 64k. In latter years you had various bank switching schemes to handle more than 64k, but the CPU knew nothing about how that worked so I'll ignore them. Of course your assembler probably just called both LDA and used other clues to select which but it was a different CPU instruction.
- rbanffy 2y agoThere are multiple, but indirect indexed (pointer + offset) is only for page zero, but you have two of them, one for X and one for Y (I don't recall the differences anymore). The 6502 was a really sweet little processor.
- rbanffy 2y ago> All that zero page addressing offers is a faster way to access memory I like to say if made me feel I had 256 general-purpose registers to play with.
- deleted 2y ago[deleted]