all repos — xyw @ 8e8d91d36f3689745d535f61f3dc52c025bd719d

A minimal virtual machine and assembler for terminals.

examples/lib/lengthw.xyw

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
; returns the length of a string (max: 255)
; a16 -[xwyw]- b16
.label lengthw
   POPxw ; store start address
   $0000 POPyw ; counter
   .label lengthw.loop
     ; if at end of string, go to end
     LDBxw $00 EQU lengthw.end JCNw
     ; otherwise increment address and counter
     INCxyw
     lengthw.loop JMPw
     .label lengthw.end
       PSHyw RTS