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

TNS Data Formats and Number Representations
HP NonStop S-Series Server Description Manual520331-003
3-6
TNS Byte Instructions
TNS Byte Instructions
Two bytes can be stored in a TNS 16-bit word. Bytes within a multibyte object or data
area are addressed and numbered according to the big-endian convention—that is, the
numbering is from left to right. Within a 16-bit word, the most significant byte occupies
WORD.<0:7> (the left half); the least significant byte occupies WORD.<8:15>. This
arrangement is shown in Figure 3-3.
Programs that assume the little-endian convention (right-to-left numbering) must be
adjusted when being converted for TNS or TNS/R processing.
Various instructions are provided in the TNS instruction set for manipulating byte
operands, either individually or as blocks of bytes. For example, bytes can be
transferred between the register stack and a memory location (LDB, STB, LBP, LBA,
SBA, LBX, SBX, LBXX, SBXX). Blocks of bytes can be moved, compared, or scanned
(MOVB, COMB, SBW, SBU, MVBX, MBXR, MBXX). Also, strings of bytes using
ASCII-coded digits can be converted to and from their corresponding quadrupleword
integer values (CAQ, CAQV, CQA).
The BTST (Byte Test) instruction is provided for testing the character class (that is,
ASCII alphabetic, numeric, or special) of a byte operand. This test is based on a
special interpretation of the condition code. This same special condition code is also
set by all byte-load instructions.
Note that byte-store operations all store the rightmost eight bits of a 16-bit register with
no overflow detection.
No instructions are provided for direct support of signed bytes, nor for arithmetic on
unsigned bytes. Arithmetic may be performed on unsigned bytes indirectly by using a
byte-load instruction (which zero-extends to 16 bits) and then using a 16-bit arithmetic
operation. The result, in this case, can be outside the range 0 through 255, and any
overflow detection is based on the 16-bit range, not on the 8-bit range.
Bytes and multibyte strings can begin at any memory address; alignment on word
boundaries is not required (as is required for all nonbyte data). Some locations cannot
be reached by 16-bit addresses. In the user data segment, locations that are
addressable by 16-bit addresses start at BYTE[0] and extend through BYTE[65535].
Two bytes are stored in each word; therefore the first 32,768 words of the data
segment (WORD[0:32767]) can store 65,536 bytes. The upper half of the data
segment, WORD[32768:65535], cannot be accessed with 16-bit addressing; this area
is byte addressable only with the use of extended addressing.
In a code segment, byte addresses are computed relative to whether the current
setting of the P (for program counter) register is in the lower or the upper half of the
code segment. Therefore, the entire code segment (WORD [0:65535]) is byte
addressable—though limited in range to half a segment at a time.
For 16-bit byte addressing of a data segment, shown in Figure 3-3, bytes 0 and 1 are
in the first TNS word of the segment, and 65,534 and 65,535 are in TNS word 32,767.
In the case of a TNS code segment, bytes 0 and 1 could be either in TNS word 0 (if the