Reference Guide
40 Chapter 3
HP-UX Architecture Conventions
Spaces
for the duration of program execution. The identifier of the code space is
placed in space register 4 (%sr4) and the identifier of the data space is
placed in space register 5 (%sr5).
When writing an assembly language program, declare a space named
$TEXT$ for executable code, and a space named $PRIVATE$ for
modifiable data. Constant data or literals that you do not plan to modify
during program execution, can be placed in either space. Placing
constant data in the $TEXT$ space decreases the size of the nonsharable
part of your program and improves the overall efficiency of the operating
system.
The particular space registers mentioned above play an important role in
virtual addressing. While many of the branching instructions, such as
BL, BLR, and BV, are capable of branching only within the currently
executing code space (called PC-space), two of the branching instructions,
BE and BLE, require that you specify a space register as well as an offset.
These instructions allow you to branch to code executing in a different
space. On HP-UX systems, normally all code for a program is contained
in one space, so all BE and BLE instructions should be coded to use %sr4.
In contrast, the memory reference instructions, such as LDW and STW,
allow a choice between two forms of addressing: long and short. With
long addressing, you can choose any of the space registers 1 through 3 for
the space identifier part of the virtual address. The space offset is formed
as the sum of an immediate displacement and the contents of a general
register. With short addressing, one of the space registers between 4
through 7 is chosen automatically, based on the high-order two bits of the
base register. Each space addressed by these four space registers is
effectively divided into four quadrants, with a different quadrant of each
space accessible via short addressing.
On HP-UX systems, all of a program's code is placed in quadrant zero of
the $TEXT$ space, or %sr4, (space offsets from 0 through 0x3FFFFFFF).
The data is placed in quadrant one of the $PRIVATE$ space, or %sr5
(space offsets from 0x40000000 through 0x7FFFFFFF). Therefore,
literal data in the code space and modifiable data in the data space can
be addressed using the short addressing technique, without any concern
for the space registers.
The identifier for shared memory segments, including shared library
text, is placed into space register 6 (%sr6). Shared memory and shared
library text are placed into quadrant two of the shared memory space
(offsets 0x80000000 through 0xBFFFFFFF). The identifier for system