In Programming the 6502 there is a chapter on IO techniques. Zak's shows a piece of code like this:
Code:
LDX COUNT
WATCH LDA STATUS
BPL WATCH
LDA INPUT
PHA
DEX
BNE WATCH
I feel I understand this, it "watches" STATUS, then when bit 7 is one, it transfers INPUT to the stack, decreases X, then goes back to watching STATUS.
He then discusses what would happen if the data you wanted to transfer was > 256 words and to large for the stack. To deal with this, he proposes to modify the code to this:
Code:
LDY #0
WATCH LDA STATUS
BPL WATCH
STA (POINTER), Y
INC (POINTER)
DEC COUNT
BNE WATCH
This I am not sure on. He is still watching the status. But then he wants to transfer the status from the accumulator to (POINTER), Y. This feels like a mistake to me. It also seems strange that he is incrementing POINTER, rather than Y.
I have been thinking about this for a while and cannot figure out his motivation here. Does anyone have any thoughts? Thanks