pTAL Guidelines for TAL Programmers

Coding Guidelines
pTAL Guidelines for TAL Programmers527256-002
2-37
Using STACK Statements to Pass Parameters
Using STACK Statements to Pass Parameters
Guideline: Pass parameters to procedures and functions using only high-level
constructs.
Do not pass parameters by pushing them onto the stack with STACK and CODE
statements. pTAL does not support the STACK or CODE statements. Example 2-37 on
page 2-37 is valid in TAL but not in pTAL.
Parameters Are Not Consecutive
Guideline: Do not assume that parameters are stored in consecutive and contiguous
memory locations.
You might have written procedures in which you assume the order in which parameters
are stored in memory and their memory locations with respect to each other.
Example 2-38 on page 2-37 makes this assumption, storing zeroes in all parameters
by using a move statement.
If your program uses code such as that in Example 2-38 on page 2-37, change the
code to assign zero to each parameter by name, as in Example 2-39 on page 2-38.
Example 2-37. Using STACK and CODE Statements to Pass Parameters
(TAL Only)
INT PROC p(i);
INT i;
BEGIN
...
STACK i; ! i is the value to pass to the caller
CODE (PUSH %711);
CODE (PCAL x); ! Assumes one parameter
END;
Example 2-38. Assuming That Parameters Are Stored Consecutively
PROC f(i, j, k, l, m, n);
INT i, j, k, l, m, n;
BEGIN
i ':=' 0 & i FOR 5 WORDS;
...
END;