HP-UX Architecture Conventions

Compiler Conventions

the return link either in a register or on the stack. Also, it can determine the previous stack pointer by subtracting the current procedure's stack frame size.

The Assembler requires that you follow programming conventions to generate unwind descriptors. The beginning and end of each procedure must be noted with the .PROC and .PROCEND directives. The .CALLINFO directive supplies additional information about the procedure, including the stack frame size. The Assembler passes this information to the linker, which creates the unwind descriptor. It can also generate the standard entry and exit code to create and destroy the stack frame, save and restore the return link (if necessary), and save and restore any necessary registers. These code sequences are generated at the points indicated by the .ENTER and .LEAVE pseudo-operations. For a more thorough discussion of programming conventions, refer to the 64-bit Runtime Architecture for PA-RISC 2.0, at URL: http://www.software.hp.com/STK/.

Arguments to procedures are loaded into general registers 26, 25, 24, and 23; these registers are named, respectively, %arg0, %arg1, %arg2, and %arg3. If more than four words of arguments are required, the remaining arguments are stored in the caller's stack frame in the variable argument list. The return value should be returned in general register 28, called %ret0. General register 29, called %ret1, is used for the low-order bits of a double-word return value, while %ret0 contains the high order bits. In addition to the argument and return registers, the procedure can use registers 19 through 22 and registers 1 and 31 as scratch registers. Any other general registers must be saved before use at entry and restored before exit.

Chapter 4, “Assembler Directives and Pseudo-Operations,” on page 53 contains detailed descriptions of the Assembler directives described above. For a more thorough discussion of the procedure calling conventions, refer to the topic PA-RISC Architecture at URL: http://www.software.hp.com/STK/.

In order for an assembly language procedure to be callable from another language or another assembly language module, the name of the procedure must be exported. The .EXPORT directive does this. It also allows you to declare the symbol type. For procedure entry points, the symbol type should be ENTRY.

The Assembler and linker treat all symbols as case-sensitive, while some compilers do not. By convention, compilers that are case-insensitive uniformly convert all exported names to lower case. For example, it is

48

Chapter 3