pTAL Guidelines for TAL Programmers
Coding Guidelines
pTAL Guidelines for TAL Programmers—527256-002
2-42
Hardware Indicators: Test Only in an IF Statement
Hardware Indicators: Test Only in an IF Statement
Guideline: Reference hardware indicators only in the conditional expression of an IF
statement.
In TAL, you can reference a hardware indicator in any expression. You must ensure
that the hardware indicator reflects the condition that you expect at the location in your
code where you reference it.
In pTAL, you can test a hardware indicator only in the conditional expression of an IF
statement. You cannot include a hardware indicator in any other type of expression.
Hardware Indicators: Test Only in Next Statement
Guideline: Test hardware indicators only in the statement that immediately follows the
statement that sets the indicator.
Example 2-45 on page 2-42, Example 2-46 on page 2-42, and Example 2-47 on
page 2-43 do not follow the guideline.
Example 2-45 on page 2-42 attempts to test the value of the condition code after
calling the READX system procedure. The move statement between the call to READX
and the IF statement, however, renders the test of the condition code invalid.
Because a move statement does not change the condition code, Example 2-45 on
page 2-42 works as a TNS process.
Example 2-46 on page 2-42 attempts to test for overflow following a signed arithmetic
operation. The USE statement, however, renders the test for $OVERFLOW invalid.
Example 2-47 on page 2-43 attempts to test the condition code following the signed
arithmetic operation in the conditional expression of the IF statement. Although the
BEGIN keyword is valid, the USE statement renders the test for CCG invalid.
Example 2-45. Invalid Condition Code Test After Procedure Call
CALL READX( fn, buffer, buffer_len, bytes_read);
save_buffer ':=' buffer FOR bytes_read BYTES;
IF < THEN... ! ERROR: Must test CCL immediately after CALL to
! READX procedure
Example 2-46. Invalid Overflow Test After Arithmetic Operation
i := i + 1;
USE j;
IF $OVERFLOW THEN... ! ERROR: $OVERFLOW must be tested
! immediately after assignment statement