Skip to main content

Conventional registers

A processor register is a small amount of memory located directly inside the CPU's microchip. It stores a simple variable such as a number. Unlike other variables that exist in main memory and are accessed via the memory bus, registers are directly accessed by CPU instructions. A typical CPU will have a fixed number of registers, often with special purposes.

Chombit provides five conventional registers: four pointer registers that store a 32-bit integer value representing a memory address, and one 8-bit register that stores the CPU flags.

Besides these conventional registers, Chombit also includes an unusual feature called framed registers, discussed separately.

The Hybrix debugger displays the conventional registers in the upper part of the CPU tab.

"CPU" tab in the Hybrix debugger

Frame pointer (FP)

This register defines the memory mapping for the so-called framed registers.

Stack pointer (SP)

The SP stack implements a conventional CPU call stack used for tracking function parameters, return addresses, and local variables.

The SP stack…

  • is managed using PUSH and POP instructions…
  • grows forwards towards larger memory addresses…
  • increments the address after pushing, and…
  • typically starts after the heap memory (IO::KERNEL_STACK_START_ADDRESS = $13_C000).

Garbage stack pointer (GP)

The garbage collector (GC) is Hybrix's kernel facility for managing the heap memory which stores objects that your program accesses using pointer variables. The GC works by scanning every pointer variable to discover all the memory objects that your program could access; any unreachable objects are then considered "garbage" and thus eligible to be freed. This scan starts from local variables that are called GC roots, where "root" means a starting point of the graph traversal. Chombit features a special "garbage stack" (commonly called the GP stack) that tracks memory addresses of program variables that are GC roots.

The GP stack…

  • is managed using GPUSH and GPOP instructions…
  • grows backwards towards smaller memory addresses…
  • decrements the address before pushing, and…
  • typically starts from the end of the RAM segment (IO::KERNEL_STACK_END_ADDRESS = $14_0000).

Since the Hybrix hardware uses a 24-bit memory bus, Chombit's GP stack is configured to store 3-byte TRIO pointers. When pushing a larger value, the extra bits are discarded.

Instruction pointer (IP)

The IP register is the CPU's program counter. It points to the memory address of the CPU instruction that is currently executing. After the instruction completes, normally the IP register will simply advance to the address of the subsequent instruction; however, this can be altered by instructions such as JUMP, IF, and POP IP.

Flags register

A special 8-bit register that stores the CPU flags.

Bit #Flag
0Zero (ZF)
1Negative (NF)
2Overflow (OF)
3Carry (CF)
4With (WF)
5Skip (SF)