pTAL Guidelines for TAL Programmers

Coding Guidelines
pTAL Guidelines for TAL Programmers527256-002
2-28
Carry Bit in ENV in Stack Marker
In pTAL, a procedure cannot access an overflow bit because the native architecture
does not have an analog to the TNS overflow bit. If you run a pTAL program that
attempts to set this bit as a native process, the results are undefined.
If you have procedures that set or reset the overflow bit in the stack marker copy of the
ENV register, you must redesign the procedures’ algorithms. For example, the
procedure can return a parameter to its caller that indicates whether an error occurred.
Carry Bit in ENV in Stack Marker
Guideline: Do not set the carry bit in the stack marker copy of the ENV register.
Do not set the carry bit in the TNS stack marker copy of the ENV register. Although
setting this bit does not cause an exception, the reasons for not accessing it are the
same as those described in Overflow Bit in ENV in Stack Marker on page 2-27.
P Register in Stack Marker
Guideline: Do not change a procedure’s return destination by storing a value into the
P register in the stack marker.
In TAL, a procedure can change the location to which it returns by storing a value in
the P-register component of the TNS stack marker, as in Example 2-26 on page 2-28,
in which procedure q stores a value in the P register component of the stack marker.
Example 2-26 on page 2-28 does not work in a native process. You must change your
code either to call the target procedure explicitly or to return a value to the caller that
specifies a procedure to call. Example 2-27 on page 2-29 introduces some overhead
but has the same effect as Example 2-26 on page 2-28 without storing into the stack
marker.
Example 2-26. Changing Return Location by Using TNS Stack Marker (TAL Only)
PROC q(i, j, k);
INT i, j, k;
BEGIN
INT p_reg = 'L' - 2;
...
p_REG := code_addr;
RETURN; ! Returns to address code_addr
END;