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

TNS Execution Modes
HP NonStop S-Series Server Description Manual520331-004
6-16
Branching, Direct and Indirect
Branching, Direct and Indirect
Addresses for branching (and for constants) in a code segment are calculated relative
to the current setting of the P register. This is referred to as P-relative addressing.
Instructions that reference a code segment have an eight-bit field (seven magnitude
bits plus a sign) for specifying a relative displacement from the current P register
setting. The range of the displacement is therefore –128:+127 words. An example,
the BUN instruction, is shown in Figure 6-9.
A branch can be either direct or indirect (an example of each is shown in Figure 6-10).
In computing a branch target address, compilers first add the displacement to the
current P register setting. This value is the direct branch address. If the referenced
location is within the range of the displacement (that is, within the range P
[-128:+127]), then direct addressing is indicated and the direct branch address is
used as the branch address. Direct addressing is specified when the indirect bit (bit
0) of the instruction is equal to 0.
If the referenced location is beyond the range of the displacement, the compiler
generates an indirect branch and the referenced location is a relative displacement
from the direct branch address. That is, the contents of the word at the direct branch
address (containing a displacement from itself) are added to the direct branch address.
The result is the target C[0]-relative branch address. Because a 16-bit word is
available to specify a displacement (not just seven bits, as in direct addressing), the
jump range is extended to the entire TNS code segment. Indirect addressing is
specified when the indirect bit of the instruction is equal to 1.
Figure 6-9. The BUN Instruction Is Typical of Branch Instructions
BUN (Branch Unconditionally) Instruction Format:
1
23456789101112131415
0
Displacement
I
0010001
VST274.vsd