browser

trimend.xyw

trimend.xyw
calendarsave
; .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