pTAL Reference Manual (H06.03+)

Hardware Indicators
HP pTAL Reference Manual523746-005
13-16
Returning the Value of $OVERFLOW or $CARRY to
the Calling Procedure
Returning the Value of $OVERFLOW or $CARRY to the Calling
Procedure
A called procedure cannot return the value of $OVERFLOW or $CARRY to its caller.
To achieve this effect, set variables with the values of these indicators and return the
variables’ values using either parameters, global variables, or return values.
Example 13-7. Returning the Value of $OVERFLOW in a Reference Parameter
PROC p; ! Calling procedure
BEGIN
INT rtn_ovfl;
CALL q(rtn_ovfl); ! q returns rtn_ovfl
IF rtn_ovfl = 0 THEN ... ! Test value of rtn_ovfl
END;
PROC q(ovfl); ! Called procedure
INT .ovfl;
BEGIN
INT i := 32767;
i := i + 1;
IF $OVERFLOW THEN ! Test hardware indicator and
ovfl := 1 ! set ovfl
ELSE
ovfl := 0;
END; ! Return ovfl to caller