pTAL Reference Manual (H06.08+)

Procedures, Subprocedures, and Procedure
Pointers
HP pTAL Reference Manual523746-006
14-4
Procedure Declarations
proc-body
is a BEGIN-END block that contains local declarations and statements, as
described in Procedure Body on page 14-17.
FORWARD
specifies that the procedure body is declared later in the compilation.
EXTERNAL
specifies that the procedure body is either declared in another compilation unit or
later in this compilation unit.
Example 14-1 on page 14-4 illustrates the following procedure declarations:
p specifies three attributes, the first and third of which are empty.
The second attribute to p, RETURNSCC, is a valid procedure, subprocedure, or
function attribute, which, if present, requires that the code execute a RETURN
statement that specifies a value from which to determine the condition code to
return to the caller. For more information about using RETURNSCC, see RETURN
on page 12-34.
The data type of the value returned by p is WADDR: namely, the address of the
global variable var. The RETURN statement sets the condition code to CCL, CCE,
or CCG, depending on whether the value of i+1 is less than, equal to, or greater
than 0.
Example 14-1. Procedure Declaration
INT var; ! var is a global INT
WADDR PROC p(i), RETURNSCC,; ! Attributes: empty, RETURNSCC,
! and empty
INT .i;
BEGIN
RETURN @var, i+1; ! Return address and
END; ! condition code value