NonStop S-Series Server Description Manual (G06.24+)

TNS Execution Modes
HP NonStop S-Series Server Description Manual520331-003
6-62
Subprocedure Calls
Subprocedure Calls
A procedure itself can contain one or more subprocedures. The following table
summarizes the differences and similarities between procedures and subprocedures.
Subprocedures are invoked using the BSUB (branch to subprocedure) instruction.
Because BSUB is a branching instruction, the subprocedure entry point is calculated
as a self-relative address. Execution of the BSUB instruction differs from other
branching instructions in that it places a return address on the top of the memory stack.
This is shown in Figure 6-34. (The right-hand part of this figure shows the same data
area three times.) Note that before BSUB executes, the subprocedure parameters
must be pushed onto the stack. Then BSUB does the following:
1. Places the return address (that of the instruction following BSUB) on the stack.
2. The branch address of the subprocedure is put into the P register.
The subprocedure uses variables and parameters in the sublocal area. This area is
addressed using the S-minus addressing mode, providing direct access to the
32 locations below and including the current S register setting—that is, S[–31:0].
The last instruction that a subprocedure executes is an RSUB (return from
subprocedure) instruction. Before RSUB executes, the S register must be
decremented, pointing at the return P location. The RSUB instruction returns control to
the instruction following the BSUB instruction by putting the return address, at the
current top of memory stack location, into the P register:
P := data [S];
S := S - S^decrement;
The “S^decrement” value (which is specified in RSUB) is used to move the S register
setting below the sublocal data area, thus deleting the one-word return address and all
parameters that were passed.
Procedure Subprocedure
Can have parameters Can have parameters
Can access local and global storage Can access local, sublocal, and global storage
Temporary storage area: 160 TNS words Temporary storage area: 32 TNS words
Local addressing modes: L-plus, L-minus Sublocal addressing mode: S-minus
Uses PCAL, XCAL, DPCL, EXIT
instructions
Uses BSUB, RSUB instructions
Has its own callability attribute Always defaults to the privilege of the
containing procedure
Can be called from other procedures and
their subprocedures
Can only be called from the local procedure
and its subprocedures
Can call subprocedures within itself (only) Can call other subprocedures (same
procedure)