pTAL Guidelines for TAL Programmers

Coding Guidelines
pTAL Guidelines for TAL Programmers527256-002
2-48
Hardware Indicators: Accessing Across Procedure
Calls
Hardware Indicators: Accessing Across Procedure Calls
Guideline: Do not set a hardware indicator and test it upon resuming execution after
calling another procedure.
Your TAL code might take advantage of information that the TNS process saves across
procedure calls, including the carry, overflow, and trap enable bits—but not the
condition code—of the environment register; however, if you call a procedure that does
not alter the condition code, either explicitly or implicitly, you can also test the condition
code upon returning from the called procedure, as in Example 2-60 on page 2-48.
In pTAL, you cannot test the value of the carry bit ($CARRY) or overflow bit
($OVERFLOW) following a procedure call, and you can test the condition code only if
the procedure you called sets the condition code. You cannot test the value of a
hardware indicator if a procedure call appears between the statement that sets the
indicator and the statement that tests the indicator.
Returning a Condition Code
Guideline: Specify the RETURNSCC procedure attribute and explicit condition code
value for procedures that return a condition code.
The enhanced TAL RETURN statement, which is available in D20 and later RVUs of
TAL, is described in the TAL Reference Manual and the TAL Programmer’s Guide.
The value returned by a function that specifies RETURNSCC must not be greater than
32 bits in length; that is, you cannot specify RETURNSCC on a function that returns a
value of data type INT(64), FIXED, or REAL(64).
In pTAL, procedures that return a condition code must specify the RETURNSCC
procedure attribute, as in Example 2-61 on page 2-49.
Example 2-60. Testing a Condition Code After a Procedure Call (TAL Only)
PROC test; ! Procedure test does not alter condition code
BEGIN
...
END;
PROC p;
BEGIN
INT i := 0;
i := i + 1; ! Set condition code
CALL test;
IF < THEN ... ; ! Condition code, if meaningful here,
END; ! does not reflect the condition code
! set by i := i + 1
! This test is valid only if PROC test
! returns a condition code