all repos — xyw @ 8e8d91d36f3689745d535f61f3dc52c025bd719d

A minimal virtual machine and assembler for terminals.

examples/lib/equals.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/macros.xyw"

; Check if two strings are equal
; a16 b16 -- a8
.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