all repos — xyw @ 8f83ba6c8680326389ba40de23c5dbef77b5c995

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
        $55 $fe00 STBw
        $0 system.error STB
    RTS

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

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