pTAL Reference Manual (H06.08+)

Built-In Routines
HP pTAL Reference Manual523746-006
15-87
$STACK_ALLOCATE
size
is an INT expression that specifies the number of bytes to allocate. size is an
unsigned value from 0 through 65534.
Difference between pTAL and EpTAL compilers:
Blocks returned by multiple calls to $STACK_ALLOCATE are not necessarily
contiguous.
$STACK_ALLOCATE returns a WADDR address, which is the lowest address in the
allocated memory.
$STACK_ALLOCATE does not clear the allocated data area.
$STACK_ALLOCATE does not return error conditions, but stack overflow can occur
within $STACK_ALLOCATE or on a subsequent procedure call from within the
procedure that calls $STACK_ALLOCATE.
When a procedure or routine returns to its caller, the system deallocates all memory
allocated by $STACK_ALLOCATE within that procedure.
pTAL does not support calls to $STACK_ALLOCATE from subprocedures and reports
a syntax error if it encounters one. From within a subprocedure, however, you can
reference data in a block allocated in the encompassing procedure.
For more information about $STACK_ALLOCATE, see the
pTAL Conversion Guide
.
pTAL Compiler EpTAL Compiler
If size is not an integral multiple of 8,
$STACK_ALLOCATE rounds size up to
the next integral multiple of 8.
If size is not an integral multiple of 32,
$STACK_ALLOCATE rounds size up to
the next integral multiple of 32.
The returned value is aligned to an 8-byte
boundary.
The returned value is aligned to a 32-byte
boundary.
Example 15-86. $STACK_ALLOCATE Routine
INT .p(template);
INT(32) .a;
INT(32) i32;
...
@p := $STACK_ALLOCATE($LEN(template));
@a := $STACK_ALLOCATE($LEN(i32)* 10);