The op code/addressing mode byte(s) may be followed by:
- No additional bytes.
- A 2-byte EA (for direct addressing only.)
- A 1- or 2-byte displacement.
- A 1- or 2-byte immediate operand.
- A 1- or 2-byte displacement followed by a 1- or 2-byte immediate operand.
- A 2-byte displacement and a 2-byte segment address (for direct intersegment addressing only).
Which of these possibilities is used is determined by the op code and addressing mode.
The op code usually occupies the first byte, and only the first byte, of an instruction, but there are a few instructions in which a register designation is in the first byte and a few other instructions in which 3 bits of the op code are in the second byte. Within most of the op codes there are special 1-bit indicators. They are:
- W-bit
- If an instruction can operate on either a byte or a word, the op code includes a W-bit which indicates whether a byte (W = 0) or a word (W = 1) is being accessed.
- D-bit
- For double-operand instructions (except for instructions with one operand being immediate and string instructions, which are discussed in Chap. 5). One of the operands must be a register specified by a REG field. For these instructions the D-bit is used to indicate whether the register specified by REG is the source operand (D = 0) or the destination operand (D = 1).
- S-bit
- A 8-bit 2's complement number can be extended to a 16-bit 2's complement number by letting all of the bits in the high-order byte equal the MSB in the low-order byte. This is referred to as sign extension. The S-bit appears with the W-bit in the immediate to register/memory add, subtract, and compare instructions and is assigned as follows:
- 8-bit operation - S:W = 00
- 16-bit operation with a 16-bit immediate operand - S:W = 01
- 16-bit operation with a sign-extended 8-bit immediate operand - S:W = 11
For small numbers, the latter case would permit the use of a 1-byte immediate operand.
- V-bit
- Used by shift and rotate instructions to determine the number of shifts (see Chap. 3).
- Z-bit
- Used by the REP instruction (which is discussed in Chap. 5).
A register designation is 2 bits long if it is for a segment register and 3 bits long if it is for any other type of register.
Figure 2-13 Examples of 8086 instruction formats.
One byte instruction - implied operand(s) |
|
|
One byte instruction - register mode | REG - Register MOD - Mode R/M - Register or memory DISP - Displacement DATA - Immediate data |
|
|
Register to register |
| |
|
Register to/from memory with no displacement |
| |
|
Register to/from memory with displacement |
| | | |
| | | (If 16-bit displacement is used) |
Immediate operand to register |
| | | |
| | | (If 16-bit data are used) |
Immediate operand to memory with 16-bit displacement |
| | | | | |
| | | | | (If 16-bit data are used) |
Table of Contents | Next page | Previous page
This is page 17.