pTAL Guidelines for TAL Programmers
Coding Guidelines
pTAL Guidelines for TAL Programmers—527256-002
2-43
Hardware Indicator: Must Be First Operand
Example 2-48 on page 2-43 follows the guidelines. READX is a file system procedure.
Hardware Indicator: Must Be First Operand
Guideline: Reference hardware indicators only as the first operand in the conditional
expression of an IF statement.
In TAL, you can reference a hardware indicator anywhere in the conditional expression
of an IF statement. In Example 2-49 on page 2-43 and Example 2-50 on page 2-43,
READX is a file system procedure.
Example 2-49
on page 2-43 is not valid in pTAL because the IF statement tests the
condition code after comparing i and j.
Example 2-50
on page 2-43 is valid in pTAL because the conditional expression tests
the hardware indicator and then compares i and j.
Example 2-47. Invalid Condition Code Test After Arithmetic Operation
IF i + j <> k THEN
BEGIN
USE x;
IF > THEN ... ! ERROR: condition code must be tested
! immediately after assignment statement
Example 2-48. Valid References to Hardware Indicators
CALL READX( fn, buffer, buffer_len, bytes_read);
IF <> THEN ... ! OK
i := i + 1; ! Signed add
IF $OVERFLOW THEN ... ! OK
i := i '+' 1; ! Unsigned add
IF $CARRY THEN ... ! OK
IF i <> j THEN ! OK
BEGIN
IF < THEN ! OK
...
END
Example 2-49. Invalid Test of a Hardware Indicator
CALL READX( ... );
IF i < j AND <> THEN ...;
Example 2-50. Valid Test of a Hardware Indicator
CALL READX( ... );
IF <> AND i < j THEN ...;