all repos — xyw @ 51f5be3e8e93c45dd88cf45723892f328abb1f84

A minimal virtual machine and assembler for terminals.

examples/lib/length.xyw

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
; Pushes the length of s
; s -> b
.label length
   POPxw ; store start address
   $00 POPx ; counter
   .label length.loop
     ; if at end of string, go to end
     LDBxw $00 EQU length.end JCNw
     ; otherwise increment address and counter
     INCxw
     INCx
     length.loop JMPw
     .label length.end
       PSHx RTS