examples/lib/trimstart.xyw
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
; .include "lib/oneof.xyw"
; Pushes the address of string trimmed at start
; s1 -> s2
.label trimstart
; Save string address
POPxw ; start address (to return) m
.label trimstart.loop
; if space, trim
PSHxw trimstart.spaces oneof JSRw
trimstart.remove JCNw
; otherwise return (at start of string)
trimstart.end JMPw
.label trimstart.remove
; remove and increment start
$00 STBxw INCxw trimstart.loop JMPw
.label trimstart.end
PSHxw RTS
.label trimstart.spaces
.byte $20 $09 $0A $0D $00
|