Skip to main content

Module stack

Module stack 

Source
Expand description

The arithmetic of the game’s own stack (crate::device).

The device gives the C stack about 10 KB, and a game’s load or search can go deeper. So the backend runs the game on a block from the heap, filled with PAINT first. A stack grows down from its top, so the painted bytes left at the bottom say how deep it ever went (high_water).

Constants§

DEFAULT_BYTES
The game’s stack unless its main! says otherwise, in bytes. The first game on the backend measured 15,256 bytes at its deepest, in its load.
PAINT
The byte the stack is filled with before the game first runs on it.
RED_ZONE
The bottom bytes of the stack that count as an overflow once used: the game has gone, or is about to go, past its stack.

Functions§

high_water
The bytes ever used of a stack of size bytes, given its bytes lowest address first: everything above the painted bytes at its bottom.
overflowed
Whether a stack, given its bytes lowest address first, has been used into its RED_ZONE. It reads that zone alone, so it can run every frame.
run
Runs f through switch, which moves to the stack, makes the call it is handed and comes back. A call made while inside says the game is on the stack already is a plain one, so it doesn’t start again from the top.
top
The starting stack pointer for a stack of size bytes at base: its top, rounded down to 8 bytes as the ARM procedure call standard asks.