all repos — xyw @ d89860e6dde57ff8a2d55511463a80e788af7863

A minimal virtual machine and assembler for terminals.

examples/on-error.xyw

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
.include "devices.xyw" 

; register on error handler
on_error system.on_error STW

; main program
$10 $0 DIV
end JMPw

; on error handler
.label on_error
    system.error $1 EQU on_error.print JCNw
    RTS
    .label on_error.print
        error print JSRw
        $2 system.error STB
    RTS

; printing subroutine
; a16 --
.label print
  POPxw
  .label print.loop
    LDBxw terminal.output STB
    INCxw LDBxw print.loop JCNw
    CLRxw
    RTS

.label error
.string "Error: Division by zero.\n"
.label end