HP-UX Architecture Conventions

Compiler Conventions

possible to declare a procedure that cannot conflict with HP Pascal/HP-UX procedure names by using uppercase letters. However, there is an aliasing mechanism in some compilers that allows you to declare a case-sensitive name for external use. See the appropriate language reference manual for more information.

Conversely, the .IMPORT directive allows you to reference a procedure name that is exported from another module, either from the Assembler or the compiler. Once a procedure name has been imported, it can be referenced exactly as if it were declared in the same module.

Data symbols can be exported and imported just like procedure names. However, not all compilers export the names of global variables, or provide a mechanism to reference data symbols exported from an assembly language module. For example, the HP Pascal/HP-UX compiler does not normally do this, while the HP C/HP-UX compiler does. HP FORTRAN 77/HP-UX named common blocks are exported, but the names of the variables within the common blocks are not.

It was mentioned before that data is allocated beginning from a virtual space offset 0x40000000. For convenience as well as compatibility with future releases of HP-UX systems, all data in the $PRIVATE$ space must be accessed relative to general register 27, called %dp. EStandard run-time start-up code, from the file /usr/ccs/lib/crt0.o, must be linked with every program. This start-up code declares a global symbol called $global$ in the $GLOBAL$ subspace. This code also loads the address of this symbol into the %dp register before beginning program execution. This register must not be changed during the execution of a program. Since the %dp register is known to contain the address of $global$, the following single instruction does the load as long as the displacement from $global$ to the desired location is less than 8 kilobytes:

LDW var-$global$(%dp),%r3

If the desired location is not known to be close enough to $global$, use the following sequence:

Global Symbol Usage

ADDIL

L'var-$global$,%dp

;result in r1

LDW

R'var-$global$(%r1),%r3

 

Chapter 3

49