Skip to content

Interrupts

CoPokBl edited this page Jan 26, 2026 · 1 revision

Cat systems support CPU interrupts which immediately stop what the CPU is doing and jump the instruction pointer to new code. You may trigger an interrupt with the int instruction manually, interrupts are also triggered by errors and user input.

Interrupts 0x00-0x0F are considered error interrupts and will halt the machine by default if not handled. All other interrupts will by default do nothing.

List

The following interrupts are given meaning by default:

Interrupt ID Name Args Handleable Description
0 Page Fault stack 32 bit pointer - accessed memory true Memory could not be accessed (out of bounds, or forbidden)
1 Invalid Instruction true Instruction opcode or arguments were invalid
2 Divide by zero true Tried to divide by zero
3 RESERVED
4 RESERVED
5 RESERVED
6 RESERVED
7 RESERVED
8 RESERVED
9 RESERVED
a RESERVED
b RESERVED
c RESERVED
d RESERVED
e RESERVED
f RESERVED
70 Receive Input r1 - device id, r2 - input type, r3 - value true
80 Write to sout r1 - pointer to string (null terminated) false
81 Halt false Pause execution permanently
82 Shutdown false Poweroff
83 Reset false Restart (ip=0)
84 Get Display Buf Start false Returns the start address of the display buffer in r0
85 Get Uptime MSEC false Returns the uptime in milliseconds in r0
86 Refresh Screen false Update the display with new data in the display buffer
90 DEBUG: Print Number r1 - number to print false Prints a number with a \n, only possible in debug mode

As shown above, some interrupts exist as function calls into the system, allowing you to do things like write to the VM's console. You can call them like functions.

Handling

You may handle interrupts by constructing an interrupt handler table and then set the IT register to a pointer to it. The structure of the table is as follows:

Offset Field Size (Bytes)
0x00 Entry Count 1
0x01 Entries 5 per entry

Then each entry is as follows:

Offset Field Size (Bytes)
0x00 Interrupt Code 1
0x01 Handler Pointer 4

Clone this wiki locally