NonStop S-Series Server Description Manual (G06.24+)
TNS Data Formats and Number Representations
HP NonStop S-Series Server Description Manual—520331-003
3-8
Instructions for Unsigned and Signed Arithmetic
Instructions for Unsigned and Signed
Arithmetic
TNS instructions that perform logical and integer arithmetic operations are named
according to TNS data lengths: TNS word, TNS doubleword, or TNS quadrupleword.
Unsigned integer arithmetic is restricted mostly to TNS word operands. Signed integer
arithmetic can be performed on all three formats.
The TNS instruction set provides arithmetic on both signed and unsigned numbers.
Signed numbers are characterized by being able to represent both positive and
negative values; unsigned numbers represent only positive values. Floating-point
numbers, described in the next topic, are always signed.
The representable range of numbers is determined by the sizes of operands (that is,
word, doubleword, and quadrupleword). The ranges are shown in Table 3-1.
Whether a word operand is treated as a signed or an unsigned value is determined by
the instruction used when a calculation is performed.
Unsigned Arithmetic
Operations on unsigned numbers are mostly restricted to 16-bit quantities (exceptions
are the doubleword shift instructions, DLLS and DLRS). Unsigned arithmetic is
indicated by the execution of logical instructions. The logical instructions provide for
arithmetic (LADD, LADI, LSUB, LMPY, LDIV), comparison and two’s-complement
negation (LCMP, LNEG), Boolean logic operations (LAND, LOR, XOR, DPF), and
16-bit or 32-bit shifts (LLS, LRS, DLLS, DLRS). The logical multiply instruction (LMPY)
returns a doubleword product, and the logical divide instruction returns a two-word
unsigned quotient with remainder.
The results obtained from a logical add or subtract (LADD or LSUB) are identical to
those obtained from integer add or subtract (see next subheading) except that logical
add and subtract never change the Overflow indicator and so these operations never
trap. (The 16-bit result, the Condition Code setting, and the Carry indicator setting are
the same.) Logical divide (LDIV), however, sets the Overflow indicator if the quotient
cannot be represented in 16 bits (unsigned).
Table 3-1. Ranges of Numbers Representable by Different Data Lengths
Data Type Range of Numbers Represented
Single TNS word –32,768 through +32,767
0 through 65,535 (unsigned)
TNS doubleword –2,147,483,648 through +2,147,483,647
TNS
quadrupleword
–9,223,372,036,854,775,808 through +9,223,372,036,854,775,807