pTAL Conversion Guide

pTAL Built-In Routines
pTAL Conversion Guide527302-002
18-47
Using Multiple Blocks Acquired From
$STACK_ALLOCATE as One Large Block
You can use the block as an array of entries, allocated from high addresses to low
addresses, by mapping each array reference to the correct array entry. This
approach, however, is very error-prone. Move operations, scan operations, string
comparison operations, and equivalencing must be used with great care and,
depending on how you access your data, might not be usable at all for such an
array. In this case, you must use different code to access array elements of TNS
and native processes, although you might be able to use defines to hide the
differences.
In this case you must either use a different indexing algorithm for TNS processes
than you use for native processes or move the data up in each TNS process
following each call to $STACK_ALLOCATE.
Figure 18-19. Memory Allocation From $STACK_ALLOCATE (TNS Process)
@p1 := $STACK_ALLOCATE (30);
@p2 := $STACK_ALLOCATE (24);
@p3 := $STACK_ALLOCATE (34);
Requested 34 bytes,
allocated 40 bytes
Requested 24 bytes,
allocated 24 bytes
Requested 30 bytes,
allocated 32 bytes
Procedure
Local
Data
Process
Global
Data
3096
3056p3
3000p1
3032p2
Direction of Stack Growth
VST018.vsd