GPUSH
Push a garbage collector root onto the GP stack.
| Opcode | Bytes | Cycles | Form | Example |
|---|---|---|---|---|
| $1E | 1 | 2 | GPUSH PUSHED | GPUSH PUSHED |
| $34 | 2 | 3 | GPUSH I:_ | GPUSH I:4 |
| $35 | 2 | 3 | GPUSH 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
GPregister), 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
TRIOpointers. When pushing a larger value, the extra bits are discarded. -
The effect of
GPUSH I:4for example is to pushI:4onto the GP stack. It first storesGP - 3inGP. Then it stores the address ofI:4(not the value ofI:4) at the memory address pointed to byGP. -
GPUSH NULL I:4for example performs all those actions and then also assigns0toI:4. This form is used to initialize a local variable to contain a null pointer. -
GPUSH PUSHEDworks differently: It first storesGP - 3inGP, then assignsSP - 4to the memory address pointed to byGP.SP - 4is assumed to be a recently pushedINTpointer. For example, if we just didPUSH I:4, thenGPUSH PUSHEDis equivalent toGPUSH I:4. -
If
IO::STACK_GUARDis 1, thenGPUSHwill trigger a stack fault event if theSPregister becomes larger than theGPregister. -
GPOP undoes the action of
GPUSH. -
This instruction does not affect the CPU condition flags.