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 bitmasks:
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 high nibble identifies the device where the error occurred:
00 - no error
0x - system error
1x - terminal error
2x - clock error
3x - file error
4x - beeper error
-> See errors for more information.
Note: the error handler must clear this error after handling it, or the error handler will keep getting executed.
=== [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.
=== [2][RW] _image_exec
Attempts to load and execute the image file specified at this address with space-separated parameters. Before the image is executed, a full snapshot of the parent image is created, and it will be restored when the child image exits. The maximum number of child images that can be executed is 8.
;system
.macro system.state $00
.macro system.error $01
.macro system.random $02
.macro system._on_error $03
.macro system._image_exec $05
=== [1][RW] state
A byte identifying the state of the virtual machine using the following values: