pTAL Guidelines for TAL Programmers
Coding Guidelines
pTAL Guidelines for TAL Programmers—527256-002
2-38
Parameters and Local Variables
Parameters and Local Variables
Guideline: Do not assume that there is a relationship between where a procedure’s 
parameters and where its local variables are stored in memory.
Example 2-40 on page 2-38 uses the pointer i to reference the value of a parameter.
Example 2-40 on page 2-38 does not work in pTAL programs that you run as native 
processes, because the code references one of the procedure’s parameters (m) 
relative to the first local variable (j). The program applies an index to a pointer—a valid 
pTAL operation—but the pTAL compiler cannot detect the error.
If your program has procedures that reference parameters or other information in the 
stack areas as in the preceding code sequence, you must find and change all such 
code to reference the parameters by name, not by their location relative to the 
procedure’s local variables.
The result of referencing data locations that occur before a procedure’s local variables 
is undefined.
Example 2-39. Not Assuming That Parameters Are Stored Consecutively
PROC g(i, j, k, l, m, n);
 INT i, j, k, l, m, n;
BEGIN
 i := 0;
 j := 0;
 k := 0;
 l := 0;
 m := 0;
 n := 0;
 ...
END;
Example 2-40. Referencing a Parameter Relative to a Local Variable
PROC p(m, n, l);
 INT m, n, l;
BEGIN
 INT j := -5; ! Negative index
 INT .i; ! Pointer
 @i := @j; ! Initialize pointer to point to first local
 i := i[j]; ! Index backwards into stack area
END;










