Skip to main content

REQUEST

Request an action from the system environment.

OpcodeBytesCyclesFormExample
$2521 + 3request {u_byte}request 123

Notes

This instruction is used to request special actions from the system environment, for example from the Hybrix debugger when it is attached. The request instruction could also be used like a software interrupt for an advanced application such as an operating system, which needs to load different programs and enable them to invoke system functions in a standardized way.

This instruction invokes a CPU event handler, which adds 3 clock cycles, plus whatever time is spent handling the event.

The table below shows the standard functions for each request number. If the Hybrix debugger or virtual machine does not handle the request, then control passes to the io::cpu_request_handler code.

Request numberFunction
0 – 15Reserved for usage by the Hybrix virtual machine and development environment.
0Break Pause your program in the debugger. This implements the Hybrix language's break statement.
1GC sweep Invokes the debugger's garbage collector to perform a "sweep" operation.
2GC mark Invokes the debugger's garbage collector to perform a "mark" operation.
16 – 255Available for usage by a custom kernel.
Useful for advanced programs such as an operating system or software debugger.

Details:

  • When a program is running in the Hybrix debugger, Break causes the debugger to pause at the address of request 0. When the program is resumed, it proceeds to invoke the framework kernel's io::cpu_request_handler.

  • When no debugger is attached, for example in the ROM Player, every request number passes directly to io::cpu_request_handler.

  • The kernel's io::cpu_request_handler ignores request number 0 (Break); for all other request numbers, it simply reports a failure.

  • The GC sweep and GC mark request codes are rarely needed. They would be used to debug memory corruption problems in an advanced program. These request functions can replace the kernel's "sweep" and "mark" operations, providing an equivalent algorithm that performs extensive safety checks.

See also