pTAL Conversion Guide

pTAL Built-In Routines
pTAL Conversion Guide527302-002
18-46
Using a Single Block Acquired From
$STACK_ALLOCATE
For TNS processes, the system allocates data blocks from smaller addresses to larger
addresses. For native processes, the system allocates data blocks from larger
addresses down to smaller addresses. This difference between how the systems
allocate memory affects how you use memory areas allocated by $STACK_ALLOCATE
and the compatibility of source code for TNS and native processes. For TNS and
native differences, see the pTAL Reference Manual.
Topics:
Using a Single Block Acquired From $STACK_ALLOCATE on page 18-46
Using Multiple Autonomous Blocks Acquired From $STACK_ALLOCATE on
page 18-46
Using Multiple Blocks Acquired From $STACK_ALLOCATE as One Large Block on
page 18-46
Using a Single Block Acquired From $STACK_ALLOCATE
If, within a procedure call, you call $STACK_ALLOCATE exactly once, you can use the
same source code for both TNS and native processes to access data within the block.
All TAL and pTAL features are compatible.
Using Multiple Autonomous Blocks Acquired From
$STACK_ALLOCATE
If, within a procedure call, you call $STACK_ALLOCATE more than once but each
allocated data area is autonomous with respect to all other data areas, you can use the
same source code for both TNS and native processes to access data within the block.
All TAL and pTAL features are compatible.
This model is appropriate to manage a linked list of entities that you access only by
using the links, never by using indexing to reference list elements.
Using Multiple Blocks Acquired From $STACK_ALLOCATE as
One Large Block
If, within a procedure call, you call $STACK_ALLOCATE more than once and you want
to use two or more contiguous blocks as one large storage area, you must consider the
following:
You can use the block as an array of entries, allocated from low addresses to high
addresses. For native processes you must physically move all entries from their
locations prior to calling $STACK_ALLOCATE down to the beginning of the newly
allocated block. In this case, your code to acquire data is different for TNS and
native processes, but you can use the same methods to access the data.