Skip to main content

GPUSH

Push a garbage collector root onto the GP stack.

OpcodeBytesCyclesFormExample
$1E12GPUSH PUSHEDGPUSH PUSHED
$3423GPUSH I:_GPUSH I:4
$3523GPUSH NULL I:_GPUSH NULL I:4

Notes

  • The GP stack is used by the Hybrix memory manager to track GC roots for the purpose of garbage collection (GC). Each GC root stores the memory address of a pointer variable that should be analyzed by the garbage collector.

  • The GP stack grows backwards (pushing decreases the GP register), whereas the SP stack grows forwards. (The "top" of the GP stack is actually the lowest memory address.)

  • 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.

  • The effect of GPUSH I:4 for example is to push I:4 onto the GP stack. It first stores GP - 3 in GP. Then it stores the address of I:4 (not the value of I:4) at the memory address pointed to by GP.

  • GPUSH NULL I:4 for example performs all those actions and then also assigns 0 to I:4. This form is used to initialize a local variable to contain a null pointer.

  • GPUSH PUSHED works differently: It first stores GP - 3 in GP, then assigns SP - 4 to the memory address pointed to by GP. SP - 4 is assumed to be a recently pushed INT pointer. For example, if we just did PUSH I:4, then GPUSH PUSHED is equivalent to GPUSH I:4.

  • If IO::STACK_GUARD is 1, then GPUSH will trigger a stack fault event if the SP register becomes larger than the GP register.

  • GPOP undoes the action of GPUSH.

  • This instruction does not affect the CPU condition flags.