Cse 216 - L7
Cse 216 - L7
Cse 216 - L7
Instruction Format
By
Lecture 7
Instruction Format
……
Low Disp / High Disp / Low High
DATA DATA DATA DATA
OP D W MOD REG R/M
CODE
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
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)