Instruction Formats of 8086
Instruction Formats of 8086
The 8086 instruction sizes vary from one to six bytes. The OP code occupies six bytes
and it defines the operation to be carried out by the instruction.
Register Direct bit (D) occupies one bit. It defines whether the register operand in byte 2
is the source or destination operand.
The second byte of the instruction usually identifies whether one of the operands is in
memory or whether both are registers.
This byte contains 3 fields. These are the mode (MOD) field, the register (REG) field and
the Register/Memory (R/M) field.
Register field occupies 3 bits. It defines the register for the first operand which is specified
as source or destination by the D bit.
The R/M field occupies 3 bits. The R/M field along with the MOD field defines the second
operand as shown below.
MOD 11
Effective Address Calculation
In the above, encoding of the R/M field depends on how the mode field is set. If
MOD=11 (register to register mode), this R/M identifies the second register operand.
MOD selects memory mode, then R/M indicates how the effective address of the memory
operand is to be calculated. Bytes 3 through 6 of an instruction are optional fields that
normally contain the displacement value of a memory operand and / or the actual value
of an immediate constant operand.
Whenever BP is used to generate the Effective Address (EA), the default segment would be SS.
In this example, we want the segment register to be DS, we have to provide the segment override
prefix byte (SOP byte) to start with. The SOP byte is 001 SR 110,where SR value is provided as
per table shown below.
To specify DS register, the SOP byte would be 001 11 110 = 3E H. Thus the 5 byte
code for this instruction would be 3E 89 96 45 23 H.
Suppose we want to code MOV SS : 2345 (BP), DX. This generates only a 4 byte code, without
SOP byte, as SS is already the default segment register in this case.
Example 5 :
Give the instruction template and generate code for the instruction
ADD OFABE [BX] [DI], DX (code for ADD instruction is 000000)
It is a word operation
Questions:
1. Give the instruction template and generate the code for the instruction
MOV AX,[BX].
2. Give the instruction template and generate code for the instruction
ADD OFABE [BX] [DI], DX (code for ADD instruction is 000 000)