hex.pointers.stack_initΒΆ
Initializes a stack of size n (maximal capacity of n hexes / return-addresses).
n is the size of the stack.
SignatureΒΆ
def stack_init n @ stack_error_handler > sp, stack { ... }
Defined in hex/pointers/basic_pointers.fj β lines 86β98 (view on GitHub).
ComplexityΒΆ
Time:
O(1)Space:
n+w/4 + 330
See the complexity glossary for what @, w, dw, dbit, n mean.
Output labelsΒΆ
This macro exposes labels into the callerβs scope via >:
spβ the stack pointer. sp always points to the last pushed value (at start - to stack[-1])stackβ the global stack.
SourceΒΆ
Click to view the macro body
def stack_init n @ stack_error_handler > sp, stack {
sp:
hex.vec w/4, .stack
pad w
stack:
hex.hex stack_error_handler
hex.vec n, 0
stack_error_handler:
stl.output "\n\nERROR: You returned on an empty stack.\n"
;0 // (would fail, so the stack trace would be printed).
}
Depends onΒΆ
Used byΒΆ
Example usesΒΆ
stl.stack_initinptrlib.fj
β Previous: hex.pointers.set_flip_and_jump_pointers
Next: hex.ptr_jump β