I'll play.
kc5tja wrote:
My code advances beyond the NUL byte of the string. So far as I can tell, yours does not. This is why Y is off-by-1 from your point of view. However, your solution uses SEC to get a free "+1" on the address fixup addition, so the end result should be the same.
Why fix it at all? why not just keep the low byte in Y,
push the address back on the stack and return?
Code:
PRIMM:
pla ; Get the low part of "return" address
tay ; (data start address)
pla ; Get the high part of "return" address
sta DPH ; (data start address)
lda #00
sta DPL
PRMORE:
iny ; Note: actually we're pointing one short
bne OUT ; first pass here fixes that
inc
OUT:
lda (DPL),y ; Get the next string character
beq PRDONE ; break loop when done
jsr CHROUT ; send data to output device
jmp PRMORE
PRDONE:
lda DPH
pha
tya
pha
rts
(no, I didn't test it to see if it actually works)
note that you only cross the page boundary once
(for each page crossing) this way. (lda(DPL),y will always be 5 cycles)