NonStop S-Series Server Description Manual (G06.24+)
TNS Execution Modes
HP NonStop S-Series Server Description Manual—520331-003
6-26
Examples of Indexing in the Data Segment
Examples of Indexing in the Data Segment
Figure 6-16 illustrates three examples of indexing in the data segment. The first shows
indexing with a direct address, the second shows indexing with an indirect address,
and the third shows indexing with a byte address—with indirection. For simplicity, the
G-relative addressing mode is assumed for all three examples; that is, all offsets for
the direct address are relative to the start of the segment, G[0]. Also assumed is that
the intent of these instructions is to access an element in a data array.
In the first example, the instruction code specifies direct addressing: bit 0 contains a 0.
It also specifies that the third of the three index registers (R[7]) contains the index
value: the index register field contains the value 3 (binary 11). The offset is 5 (binary
101). To compute the referenced address, the offset value (5) is taken as the base of
the array, at location G[5], and the value in the specified index register (12) is added to
that base to arrive at the element address, location G[17].
In the second example, bit 0 of the instruction code specifies indirect addressing
(contains 1). The index register field contains the value 2, thus specifying the second
of the three index registers, R[6]. The offset is 10 (binary 1010). Computation of the
referenced address occurs in two steps. First, the content of the location at the direct
address, specified by the offset value (10), is read and taken as the base of the array.
As indicated, the base address is 1234. As the second step, the content of the
specified index register (7) is added to the base address to arrive at location G[1241].
In the third example, which is assumed to be a byte-referencing instruction, indirect
addressing is again specified. The third of the three index registers is specified, and
the offset is 2. The index value is a negative number, –7. The first step in computing
the referenced byte address is to read the content of the location at the direct address;
the direct address is G[2], as specified by the offset, and the content is 12345. This
value, 12345, is the base of the array, given as a byte address. Adding the content of
the specified index register (–7) to this base gives an element address of 12338. To
convert this byte address to a word address plus byte identifier, it is divided by 2, giving
a word address with a remainder of 0. The word address, indexed negatively from the
base, is location G[6169], and the byte specified is the left half of that word.
In the case of doubleword operands, the indexing value is a doubleword. It is
multiplied by 2 to provide a word index. This value is added to the appropriate base
address (also a word address): either to the initial address for direct addressing, or to
the indirect address pointer for indirect addressing.