System Device
device-systemThe System device provides mapping for system-defined registry like stack pointers, program counter, and also user-defined registers. It also provides ways to check the status of the system, debugging, and managing errors.
00000000 - system off
00000001 - system running
00000002 - system waiting for event
Plus, as needed, the following bit asks:
01000000 - debug mode enabled
10000000 - error
If an error occurs, the error bit will be set as long as an error is set in the appropriate byte (see below).
=== [1][RO] error
A byte indicating the last error. The following values are supported:
00 - no error
0x - system error
1x - terminal error
2x - clock error
3x - file error
4x - beeper error
Note: the error handler must clear this error after handling it, or the error handler will keep getting executed.
=== [1][RW] page
Specifies the memory page to use as direct page for fast access to variables using LDD an STD instructions.
Note: The direct page is set to the devices page ($FF) by default, to enable single-bit addressing for devices.
=== [1][RO] random
When read, returns a random value between 0 and 255.
=== [2][RW] on_error
Address of the subroutine that will be executed in case of an error.
;system
.macro system.state $00
.macro system.error $01
.macro system.page $03
.macro system.random $04
.macro system.on_error $06
=== [1][RW] state
A byte identifying the state of the virtual machine using the following values: