HPlogo HP Assembler Reference Manual: HP 9000 Computers > Chapter 4 Assembler Directives and Pseudo-Operations

.CALLINFO Directive

» 

Technical documentation

Complete book in PDF

 » Table of Contents

 » Index

.CALLINFO is a required directive that describes the environment of the current procedure. The information it provides is available to the .ENTER and .LEAVE pseudo-operations to control the entry and exit code sequences that they generate. Additional information is used by the Assembler to direct the creation of stack unwind descriptors.

Syntax

.CALLINFO [parameter [, parameter]...]

where parameter is one of:

ALLOCA_FRAME
ARGS_SAVED
CALLER
CALLS
NO_CALLS
CLEANUP
ENTRY_FR=number
ENTRY_GR=number
ENTRY_SR=number
FRAME=number
HPUX_INT
MILLICODE
NO_UNWIND
SAVE_MRP
SAVE_RP
SAVE_SP
SAVE_SR0

Parameters

ALLOCA_FRAME

Indicates that this procedure allocates temporary storage by modifying the stack pointer (%r30). A copy of the frame pointer is normally placed in %r3. However, if this procedure also has a large frame (FRAME > 8191), then the copy of the frame pointer is placed in %r4 instead.

ARGS_SAVED

Indicates that this procedure stores the arguments into the stack frame.

CALLER or CALLS

Indicates that this procedure calls other routines, so it requires space in the stack for a frame marker and a fixed argument list. (When a program is assembled using the -f option, this becomes the default case.)

The Assembler allocates stack space when it encounters an .ENTER pseudo-operation and deallocates this space when it encounters a .LEAVE pseudo-operation. The Assembler allocates 48 bytes for the PA-RISC 32-bit mode and 80 bytes for the PA-RISC 64-bit (2.0W) mode.

The frame marker and fixed argument list area occur at the top of the stack so you must take this space into account when locating local variables on the stack. You must allocate an area (using FRAME=) for a variable argument list when this area is needed.

CALLER does not imply the existence of the parameter SAVE_RP.

The CALLER and CALLS parameters are equivalent.

NO_CALLS

Indicates that the procedure does not call other procedures and, therefore, does not require a frame marker on the stack. This is the default case unless the program is assembled using the -f option.

CLEANUP

Indicates that this procedure requires cleanup during unwind.

ENTRY_FR= register

Specifies the high end boundary of the Entry/Save floating-point register partition. The partition includes %fr12 through %fr15 for PA-RISC 1.0 and %fr12 through %fr21 for PA-RISC 1.1. The Assembler automatically saves these registers when it encounters an .ENTER pseudo-operation and restores them when it encounters a .LEAVE pseudo-operation.

ENTRY_GR= register

Specifies the high end boundary of the Entry/Save register partition. The partition may extend over registers %r3 through %r18. If you omit this parameter, no registers are saved.

When a procedure uses these registers, the Assembler saves their values when it encounters an .ENTER pseudo-operation and restores these values when it encounters a .LEAVE pseudo-operation. The called routine saves these registers upon entry and restores them upon exit, so values in Entry/Save registers are preserved across a procedure call.

Note: See the description of the FRAME parameter regarding the use of %r3.

ENTRY_SR= register

Specifies the high end boundary of the space register partition. The partition currently contains only %sr3. When the .CALLINFO directive includes this parameter, the Assembler automatically saves the Space Register when it encounters an .ENTER pseudo-operation and restores this register when it encounters a .LEAVE pseudo-operation.

FRAME=number

Defines the combined size (in bytes) of the local variable area and variable argument area needed by the procedure. The .ENTER pseudo-operation allocates the desired space for local variables below the frame marker and the .LEAVE pseudo-operation deallocates that space.

The number parameter must be a multiple of eight bytes. If a .CALLINFO directive lacks this parameter, the Assembler assumes a default frame size of zero.

The stack frame includes space for local variables and the variable argument area. The size specified for the frame should not include space for the stack frame marker or the fixed argument area. Allocation of these areas is controlled by the CALLER and NO_CALLS parameters. The inclusion of the CALLER parameter always allocates space for the stack frame marker and the fixed argument area. (See Table 4-1 “Assembler Directives”)

A frame marker is required if the assembly routine calls another routine.

For PA-RISC 32-bit mode, the frame area is offset from the Stack Pointer by 48 bytes because the frame marker contains 32 bytes and the fixed argument list contains 16 bytes, when both of these areas are present.

For PA-RISC 2.0W (64-bit mode), the frame area is offset from the Stack Pointer by 80 bytes because the frame marker contains 16 bytes and the fixed argument list contains 64 bytes.

However, the Assembler does not allocate space for the frame marker and fixed argument list if the procedure does not call any other routines (see the NO_CALLS parameter).

If the total frame size for a procedure exceeds 8191 bytes, the Assembler uses %r3 to locate the previous frame marker when it encounters an .ENTER or .LEAVE pseudo-operation. Under these circumstances, changing the value of %r3 can cause serious consequences.

HPUX_INT

Specifies that this procedure is an interrupt procedure. This is necessary for the stack unwind mechanism.

MILLICODE

Indicates to the unwind mechanism that this is a millicode routine and it should follow the millicode calling conventions.

NO_UNWIND

This is to be used only in the context of stand-alone code or any procedure that does not need to be reliably unwound.

RP_IN_R31

Indicates that the return pointer has been moved to register %r31 in order to make local millicode calls. This parameter is only valid for the PA-RISC 2.0W (64-bit mode).

SAVE_MRP

Indicates that this millicode procedure saves the Millicode Return Pointer (MRP) in its frame marker at (SP-20).

SAVE_RP

Specifies that the frame marker of the previous routine stores the value of the Return Pointer (RP). The Assembler automatically saves the Return Pointer when it encounters an .ENTER pseudo-operation, and it restores the RP value when it encounters a .LEAVE pseudo-operation. Generally, any procedure that calls other routines should save the RP value.

SAVE_SP

Specifies that the current routine saves the value of Previous_SP in its frame marker at SP-4. Because the Assembler does not automatically save the Stack Pointer when it generates Entry/Exit code sequences, you must explicitly save this value in your program when using this key word. You can obtain the Previous_SP value from the special register %previous_sp.

Programming languages, such as HP Pascal/HP-UX, typically use this value for up-level display pointers to reference local variables.

SAVE_SR0

Indicates that this millicode procedure saves %sr0 in its frame marker at (SP-16). This parameter is not valid for PA-RISC 2.0W (64-bit mode).

Discussion

When a program uses the .CALLINFO directive, all entry and exit code must follow the procedure calling convention described in the documents under the topic PA-RISC Architecture at URL: http://www.software.hp.com/STK/. If you use the .ENTER and .LEAVE directives, the Assembler will automatically generate the necessary code. The parameters in the .CALLINFO directive govern the generation of the Entry/Exit code sequence (except for SAVE_SP). However, if you use the .ENTRY and .EXIT directives, your code must provide the necessary Entry/Exit code sequences.

A stack frame consists of a pointer to the top of the frame, a frame marker, a fixed argument list, and a variable argument list. The following example, Example 4-1 “Stack Frames”, illustrates these areas as an inverted stack for PA-RISC 1.x and 2.0.

NOTE: For PA-RISC 2.0W, 64-bit mode, the stack frame is different. Refer to the documents under the topic PA-RISC Architecture at URL: http://www.software.hp.com/STK/.

Example 4-1 Stack Frames

                         Variable Arguments
. . .
SP-64: arg word 7
SP-60: arg word 6
SP-56: arg word 5
SP-52: arg word 4

Fixed Arguments

SP-48: arg word 3 / ARG3
SP-44: arg word 2 / ARG2
SP-40: arg word 1 / ARG1
SP-36: arg word 0 / ARG0

Frame Marker

SP-32: Saved %r19 for shared library calls.
SP-28: Reserved
SP-24: Saved RP for shared library calls.


SP-20: Saved RP (or SAVED_MRP).

SP-16: Static Link (or SAVED %sr0).
SP-12: Clean Up.
SP-8: Extension Pointer. Calling stub RP (RP").
SP-4: Previous SP.

Top of Frame

SP: Stack Pointer.

Example

This example uses the C printf() routine (see printf(3S) in HP-UX Reference). It illustrates most of the directives to be used when assembly language programmers follow the standard procedure calling conventions described in the documents under the topic PA-RISC Architecture at URL: http://www.software.hp.com/STK/.

 .CODE                          ; declare space and subspace
main
.PROC ; delimit procedure entry
.CALLINFO CALLER,FRAME=0,SAVE_RP ; no local variables, need return
.ENTER ; insert entry code sequence
ADDIL L'stringinit-$global$,%r27 ; point to data to be printed
LDO R'stringinit-$global$(%r1),%r26 ; place argument to printf
.CALL ; set up for procedure call
BL printf,%r2 ; call printf, remembering from where
NOP
.LEAVE ; insert exit code sequence
.PROCEND ; delimit procedure end

.DATA ; declare space and subspace
stringinit ; mark use of global data subspace
.IMPORT $global$,DATA ; get data reference point
.CODE ; re-enter code subspace
.EXPORT main,ENTRY ; make routine known to linker
.IMPORT printf,CODE ; external procedure declaration
.END
© 1998 Hewlett-Packard Development Company, L.P.