String length: Difference between revisions

m (→‎Byte Length: formatting)
Line 63:
12
</pre>
 
=={{header|6502 Assembly}}==
{{trans|Z80 Assembly}}
Most 6502-based computers predate Unicode, so only byte length will be demonstrated for now.
<lang 6502asm>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 doubles as the pointer to the chars in the string and our length counter
 
loop_getStringLength:
LDA ($00),y
BEQ exit
INY
JMP loop_getStringLength
 
exit:
RTS ;string length is now loaded into Y.</lang>
 
=={{header|4D}}==
1,489

edits