all repos — xyw @ 3a2ebec18c570de453e3e5b7f76158f0f82a5c58

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
; 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