 |
NeedStack |
Function (ROM Call 0xA4) |
Checks for space on the stack.
NeedStack throws a memory error if there is no enough space on the processor stack for Size bytes
(the hardware stack is 16K in size; when a function calls another function the system will throw an
error if there is not enough hardware stack to make the call).
Although this routine is used mainly internally in TIOS, sometimes it may be useful even
in user programs. For example, a function may have a complex set of operations that may not be
easily undone in a ONERR block. The function may also require
that all of the operations do not fail due to a lack of hardware stack. In this case, the
function can be started with a call to NeedStack to at least guarantee that
the hardware stack will not overflow during the critical section of the function.
Critical operations may be, say, direct modifying elements of the VAT table. So, if the
function calls NeedStack first, this insures
that none of the critical operations are partially completed due to a lack of
hardware stack thus leaving the VAT table (for example) in an undefined state. The
TI-Basic interpreter uses the hardware stack to make recursive calls and
so all TI-Basic commands and functions cannot rely on the hardware
stack being at any particular level.
Used by: HeapAlloc, HeapAllocESTACK, HeapAllocHigh, HeapAllocPtr, HeapCompress, HeapFree, HeapMoveHigh, HeapRealloc, malloc, cmd_custom, cmd_dialog, cmd_request, cmd_toolbar, Parse2DExpr, Parse2DMultiExpr, handleRclKey, handleVarLinkKey, getcalc, GraphActivate, VarStore, ROM Call 0x438