Instruction formats of 8086

Posted By on September 21, 2014


Download PDF
Flag Registers of 8086
Segmentation in 8086

 

         

 

       
         
       

Instruction formats of 8086 :

The instruction format of 8086 has one or more number of fields associated with it.

The first filled is called operation code field or opcode field, which indicates the type of operation.

The instruction format also contains other fields known as operand fields.

There are six general formats of instructions in 8086 instruction set. The length of an instruction may vary from one byte to sic bytes.

a) One byte Instruction : This format is only one byte long and may have the implied data or register operands. The least significant 3 bits of the opcode are used for specifying the register operand, if any. Otherwise, all the eight bits form an opcode and the operands are implied.

For example:

1 1 1 1 1 0 0 0 CLC : clear carry

This is an operation without any operand, which clear the carry flag bit.

10010 reg

Exchange register with accumulator

Depending on the register (reg = RRR), the contents of the specified register will be exchanged with the accumulator. This operation is having one operand which is specified in a register.

ASC Adjust for addition AAA 00110111

Here the operand to this instruction is implicit and it take the contents of register AL.

b) Register to Register : This format is 2 bytes long. The first byte of the code specifies the operation code and the width of the operand specifies by w bit. The second byte of the opcode shows the register operands and RIM field.

OP CODE d w WWWWW

1 1 REG R/M

The register represented by the REG field is one of the operands. The RIM field specifies another register or memory location, ie., the other operand. The register specified by REG is a source operand if , else it is a destination operand.

For example:

MOV : data transfer operation from Register to Register.

Op-code is

1 0 0 0 1 0 d w

1 1 R E G

1 0 0 0 1 0 0 0 1 1 0 0 0 0 0 1

REG = 0 0 0 indicates Register AL

REG = 0 0 1 indicates Register CL

indicates it is a byte operation (8 bit)

indicates AL is a source register.

This instruction indicates MOV CL, AL, i.e CL AL

C) Register to/from memory with no displacement : This format is also 2 bytes long and similar to the register to register format except for the MOD field.

OP CODE d w WWWWW

MOD REG R/M

The MOD field shows the MOD of addressing. In case of no displacement. MOD = 00

For example :

MOV : Data transfer Register/memory to/from register.

1 0 0 0 1 0 d w

mod reg rim

This format is similar to register to register transfer. The difference is in mood field.

For register to register, mod = 11

For register to/from memory with no displacement, mod = 00.

When mod = 0 0, the r/m fields indicates the address to memory location.

As for example r/m = 1 1 1 indicates (Bx)

The instruction

1 0 0 0 0 1 0 1 0 0 0 0 0 0 1 1 1 indicates the instruction MOV AX, [BX]

In hexadecimal, the instruction is

Here the data is present in a memory location in DS whose offset address is in BX. The effective address of the data is given as

There indicates AX is a destination register so it moves the data from memory to register.

d) Register to/from Memory with Displacement :

This type of instruction format contains one or two additional bytes for displacement along with 2-byte the format of the register to/from memory without displacement.

MOD REG R/M

Low byte of displacement

opcode

High byte of displacement

MOD = 0 1 indicates displacement of 8 bytes (instruction is of size 3 bytes)

MOD = 1 0 indicates displacement of 16 bytes. (instruction is of size 4 bytes)

Already we have seen the other two options of MOD

MOD = 1 1 indicates register to register transfer

MOD = 0 0 indicates memory without displacement

In this case, R/M fields indicates a memory when MOD is not 1 1

R/M = 1 1 1 indicates (BX)

When MOD = 0 1, the offset address is

When MOD = 1 0, the offset address is

e) Immediate operand to register

In this format, the first byte as well as the 3 bites from the second byte which are used for REG field in case of register to register format are used for opcode. It also contains one or two bytes of immediate data.

Op code w

1 1 op code R/M

Lower byte DATA

Higher byte DATA

When , the size of immediate data is 8 bits and the size of instruction is 3 bytes.

When , the size of immediate data is 16 bits and the size of instruction is 4 bytes.

f) immediate operand to memory with 16-bit displacement : This type of instruction format requires 5 to 6 bytes for coding. The first two bytes contain the information regarding OPCODE, MOD and R/M fields. The remaining 4 bytes contain 2 bytes of displacement and 2 bytes of data.

Op code w

MOD op code R/M

Higher byte of

displacement

Lower byte of DATA

Higher byte of

DATA

The REG code of the different registers (either a source or destination operands) in the opcode byte are assigned with binary code.

w

bit

Register code

(3 bit)

Registers

Segment register code (2 bit)

Segment register

0

0 0 0

A
L

0 0

E S

0

0 0 1

CL

0 1

C S

0

0 1 0

DL

1 0

S S

0

0 1 1

BL

1 1

D S

0

1 0 0

AH

   

0

1 0 1

CH

   

0

1 1 0

DH

   

0

1 1 1

BH

   

1

0 0 0

AX

   

1

0 0 1

CX

   

1

0 1 0

DX

   

1

0 1 1

BX

   

1

1 0 0

SP

   

1

1 0 1

BP

   

1

1 1 0

SI

   

1

1 1 1

DI

   
         
         
         
         
         
         
         
         
         
         
         
         
         
Flag Registers of 8086
Segmentation in 8086

Download PDF

Posted by Akash Kurup

Founder and C.E.O, World4Engineers Educationist and Entrepreneur by passion. Orator and blogger by hobby

Website: http://world4engineers.com