pTAL Conversion Guide

TAL Standard Routines
pTAL Conversion Guide527302-002
17-4
pTAL
$CARRY cannot be an actual parameter. If it is important to pass the value of $CARRY
to a procedure, use code similar to that in Example 17-2 on page 17-4.
Do not treat $CARRY as a global variable by altering it in one procedure and testing in
another. Example 17-3 on page 17-4 is valid in TAL, but not in pTAL.
For more information about $CARRY, see Section 20, Hardware Indicators.
Example 17-1. Procedure That Returns $CARRY (TAL)
PROC p1(i, j);
INT .i, j;
BEGIN
i := j + 1; ! Sets $CARRY to 0 or 1
END;
PROC p2;
BEGIN
INT a; ! Local variable
CALL p1(a, 4);
IF $CARRY THEN ... ! Testing $CARRY works in TAL
END; ! pTAL compiler reports error:
! $CARRY is not available after a
! procedure call
Example 17-2. Passing the Value of $CARRY to a Procedure (pTAL)
INT a, carry_flag;
carry_flag := 0;
a := a + 1;
IF $CARRY THEN carry_flag := 1;
CALL p1(carry_flag, .... );
Example 17-3. Treating $CARRY as a Global Variable (TAL)
PROC p1;
BEGIN
IF $CARRY THEN ... ! Testing value of $CARRY set in p2
END; ! works in TAL but not in pTAL
PROC p2;
BEGIN
INT a; ! Local variable
...
a := a '+' 1; ! Sets $CARRY to 0 or 1
CALL p1;
END;