browser

equals.xyw

equals.xyw
calendarsave
; Pushes $01 if s1 == s2, $00 otherwise
; s1 s2 -> f
.label equals 
  ; save addresses to registers
  POPyw POPxw 
  ; if same address, then it's the same string 
  EQUxyw equals.ok JCNw
  .label equals.loop
    ; if chars are different, fail
    LDBxyw NEQ equals.fail JCNw
    ; chars at the same
    ; if one is end of string, ok
    LDBxw $00 EQU equals.ok JCNw
    ; otherwise continue
    INCxyw equals.loop JMPw
  .label equals.fail
    $00 RTS
  .label equals.ok
    $01 RTS