pTAL Conversion Guide

Hardware Indicators
pTAL Conversion Guide527302-002
20-28
Returning the Condition Code to a Caller
Returning the Condition Code to a Caller
In pTAL, a called procedure can return a condition code value to its caller by using the
RETURNSCC procedure attribute in the procedure declaration, and new syntax in a
RETURN statement (see RETURN Statement on page 15-19).
A called procedure cannot return the value of overflow or carry to its caller. You must
set variables with the values of these indicators and return the variable’s value using
parameters, global variables, or return values. Example 20-19 on page 20-28 returns
the value of $OVERFLOW in a reference parameter.
PROC a;
BEGIN
INT i, j, k;
...
j := i;
IF <> THEN k := 1
ELSE k := 0;
CALL b(k); ! Call b, which tests the value of k
END;
Example 20-19. Returning the Condition Code to a Caller (pTAL)
PROC p;
BEGIN
INT rtn_ovfl;
CALL q(rtn_ovfl);
IF rtn_ovfl = 0 THEN...
END;
PROC q(ovfl);
INT .ovfl;
BEGIN
INT i := 32767;
i := i + 1;
IF $OVERFLOW THEN
ovfl := 1
ELSE
ovfl := 0;
END;
Example 20-18. Using Hardware Indicators Across Procedures
(pTAL) (page2of2)