Hugo Holden
Veteran Member
I'm trying to write an assembly language program which can enter or read values to memory from page 04 upwards and I don't want to use any page 0 locations for the program or data. The program will sit just at the top of page 03.
I can easily write to a page of memory, for example with STA $0400,X and increment the x register from 00 to FF, so easy to write, to up to address $04FF. But at that point I have not found a way yet to auto increment the high byte 04 to the next page at 05.
I have tried using the indirect indexed format for example STA (ADDR),X where ADDR was the label as an address with a .WORD (& I tried a byte) assembler directive, and holds two bytes (which I could modify to change the address), but this address method only appears to work for page 0 addresses. And I get assembly errors when I try it.
( When I was doing some 8080 assembly, I didn't have this issue, because to generate an address that could be incremented or decremented across the span $0000 to $FFFF, it would work with the H-L "register pair" and was dead easy)
So the question is; what is the better method (routine) to generate sequential 16 bit addresses across the full range of say $0400 to $FFFF in 6502 assembly language, where the total address value can be incremented or decremented, that will work with LDA and STA to read and write from & to memory and doesn't use page 0 memory ?
I can easily write to a page of memory, for example with STA $0400,X and increment the x register from 00 to FF, so easy to write, to up to address $04FF. But at that point I have not found a way yet to auto increment the high byte 04 to the next page at 05.
I have tried using the indirect indexed format for example STA (ADDR),X where ADDR was the label as an address with a .WORD (& I tried a byte) assembler directive, and holds two bytes (which I could modify to change the address), but this address method only appears to work for page 0 addresses. And I get assembly errors when I try it.
( When I was doing some 8080 assembly, I didn't have this issue, because to generate an address that could be incremented or decremented across the span $0000 to $FFFF, it would work with the H-L "register pair" and was dead easy)
So the question is; what is the better method (routine) to generate sequential 16 bit addresses across the full range of say $0400 to $FFFF in 6502 assembly language, where the total address value can be incremented or decremented, that will work with LDA and STA to read and write from & to memory and doesn't use page 0 memory ?