pTAL Reference Manual (G06.24+, H06.09+, J06.03+)
Example 200 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
Example 200 (page 248) 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 (page 223).
• 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.
Procedure Attributes
Procedures can have the following attributes:
MAIN
causes the procedure to execute first when you run the program. When the MAIN procedure
completes execution, it passes control to the PROCESS_STOP_ system procedure, rather than
executing an EXIT instruction.
If more than one procedure in a compilation has the MAIN attribute, the compiler emits a
warning and uses the first main procedure it sees as the main procedure. For example, in the
following source code, procedures main_proc1 and main_proc2 have the MAIN attribute,
but in the object file only main_proc1 has the MAIN attribute:
PROC main_proc1 MAIN; ! This MAIN procedure is MAIN
BEGIN ! in the object file
CALL this_proc;
248 Procedures, Subprocedures, and Procedure Pointers