browser

trimstart.xyw

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