RosettaCodeData/Task/String-length/6502-Assembly/string-length.6502

13 lines
394 B
Plaintext

GetStringLength: ;$00 and $01 make up the pointer to the string's base address.
;(Of course, any two consecutive zero-page memory locations can fulfill this role.)
LDY #0 ;Y is both the index into the string and the length counter.
loop_getStringLength:
LDA ($00),y
BEQ exit
INY
JMP loop_getStringLength
exit:
RTS ;string length is now loaded into Y.