Hardware Reference
In-Depth Information
which loads the byte register AL from the address computed from AL
+
BX . This
instruction allows for rapid lookup in tables of size 256 bytes.
Officially defined in the 8088, but not implemented in the interpreter (and thus
not listed in Fig. C-4), are the IN and OUT instructions. These are, in fact, move
instructions to and from an I/O device. The implied address is always the AX regis-
ter, and the second operand in the instruction is the port number of the desired de-
vice register.
In the second block of Fig. C-4 are the addition and subtraction instructions.
Each of these has the same three operand combinations as MOV : effective address
to register, register to effective address, and constant to effective address. Thus, the
Operands column of the table contains r
# . In all four of these
instructions, the overflow flag, O , the sign flag, S , the zero flag, Z , and the carry
flag, C are all set, based on the result of the instruction. This means, for example,
that O is set if the result cannot be correctly expressed in the allowed number of
bits, and cleared if it can be. When the largest 16-bit number, 0x7fff (32,767 in
decimal), is added to itself, the result cannot be expressed as a 16-bit signed num-
ber, so O is set to indicate the error. Similar things happen to the other status flags
in these operations. If an instruction has an effect on a status flag, an asterisk (*) is
shown in the corresponding column. In the instructions ADC and SBB , the carry
flag at the start of the operation is used as an extra 1 (or 0), which is seen as a carry
or borrow from the previous operation. This facility is especially useful for repre-
senting 32-bit or longer integers in several words.
e , e
r , and e
For all additions and subtrac-
tions, byte versions also exist.
The next block contains the multiplication and division instructions. Signed
integer operands require the IMUL and IDIV instructions; unsigned ones use MUL and
DIV . The AH : AL register combination is the implied destination in the byte version
of these instructions. In the word version, the implied destination is the AX : DX
register combination. Even if the result of the multiplication is only a word or a
byte, the DX or AH register is rewritten during the operation. The multiplication is
always possible because the destination contains enough bits. The overflow and
carry bits are set when the product cannot be represented in one word, or one byte.
The zero and the negative flags are undefined after a multiply.
Division also uses the register combinations DX : AX or AH : AL as the destina-
tion. The quotient goes into AX or AL and the remainder into DX or AH . All four
flags, carry, overflow, zero and negative, are undefined after a divide operation. If
the divisor is 0, or if the quotient does not fit into the register, the operation
executes a trap , which stops the program unless a trap handler routine is present.
Moreover, it is sensible to handle minus signs in software before and after the
divide, because in the 8088 definition the sign of the remainder equals the sign of
the dividend, whereas in mathematics, a remainder is always nonnegative.
The instructions for binary coded decimals, among which Ascii Adjust for
Addition ( AAA ), and Decimal Adjust for Addition ( DAA ), are not implemented by
the interpreter and not shown in Fig. C-4.
 
Search WWH ::




Custom Search