examples/lib/trimend.xyw
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
; .include "lib/oneof.xyw"
; Remeve space chars at end of string
; s ->
.label trimend
; save string address
POPxw
.label trimend.toend
LDBxw $00 EQU trimend.loop JCNw
; increment till end
INCxw trimend.toend JMPw
.label trimend.loop
DECxw PSHxw trimend.spaces oneof JSRw
; if space, remove and decrement
trimend.remove JCNw
; otherwise return
RTS
.label trimend.remove
$00 STBxw trimend.loop JMPw
.label trimend.spaces
.byte $20 $09 $0A $0D $00
|