Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Cse 216 - L7

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

8086 Microprocessor

Instruction Format

By

Lecture 7
Instruction Format

• 8086 instruction size vary from one to six bytes

BYTE 1 BYTE 2 BYTE 3 BYTE 4 BYTE 5 BYTE 6

……
Low Disp / High Disp / Low High
DATA DATA DATA DATA
OP D W MOD REG R/M
CODE

Register operand / Register to use in EA calculation


Register operand / Extension of Op code
Register operand / Memory mode with displacement length
Word/Byte operation

Direction is to Register/ Direction is from Register

Operation Code
Byte1

• Opcode
• occupies six bits
• Defines the operation to be carried out by the instruction.
• Example: MOV=1000102
• Register direction bit (D)
• occupies one bit
• D=0, when the register operand in byte 2 is source.
• D=1, when the register operand in byte 2 is destination.
• Data size bit (W)
• occupies one bit
• W=0, indicates 8 bit operation.
• W=1, indicates 16-bit operation.
REG W=0 W=1

Byte 2 000 AL AX
001 CL CX
010 DL DX
• MOD
• occupies two bits 011 BL BX
• 00 - Memory mode with no displacement follows 100 AH SP
and 16 bit displacement when R/M=110
101 CH BP
• 01 -Memory mode with 8-bit displacement
110 DH SI
• 10 -Memory mode with 16-bit displacement
• 11 -Register mode 111 BH DI

• REG field R/M W=0 W=1


• Occupies three bits 000 AL AX
• Defines the register which is specified in the D-bit
001 CL CX
of byte 1 as source or destination.
• Specifies register with W -bit 010 DL DX

• R/M field 011 BL BX


• occupies three bits 100 AH SP
• Definition depends on MOD field 101 CH BP
• When MOD=11, this field specifies second register,
depending on W bit as REG. 110 DH SI
• For other MOD values this field specifies the 111 BH DI
pointers used in effective address calculation
R/M field specification for effective address calculation

Effective address calculation


R/M MOD = 00 MOD = 01 MOD=10

000 [BX]+[SI] [BX]+[SI]+ D8 [BX]+[SI]+ D16

001 [BX]+[DI] [BX]+[DI]+ D8 [BX]+[DI]+ D16

010 [BP]+[SI] [BP]+[SI]+ D8 [BP]+[SI]+ D16

011 [BP]+[DI] [BP]+[DI]+ D8 [BP]+[DI]+ D16

100 [SI] [SI]+D8 [SI]+D16

101 [DI] [DI]+D8 [DI]+D16

110 Direct address [BP]+D8 [BP]+D16

111 [BX] [BX]+D8 [BX]+ D16


Byte3
• Defines 8 bit displacement
• Defines low 8 bit of 16 bit displacement
• Low 8-bit of immediate data (immediate addressing)

Byte 4
n Defines high 8 bit of 16 bit displacement
n High 8-bit of immediate data (immediate addressing)

Byte 5
n Low 8-bit of immediate data (immediate addressing) when byte 3
and 4 are used for displacement
Byte 6
n High 8-bit of immediate data (immediate addressing) when byte 3
and 4 are used for displacement
Example
• Machine code for: MOV AX, BX (Machine code for MOV=100010)
• 100010 0 1 11 011 000
MOV D W MOD REG R/M

• Machine code for: SUB AL, [BP][SI] (Machine code for SUB=001010)
• 001010 10 00 000 010
SUB D W MOD REG R/M

• Exercise
• Machine code for: SUB CL, [BX][DI]200h (Machine code for SUB=001010)
• Machine code for: MOV [SI]2304h, 4050h (Machine code for MOV=100010)

You might also like