Professional Documents
Culture Documents
Addr Mode
Addr Mode
low addr
opcode
mod
high addr
reg
d w
r/m
optional
optional
optional
Low Immediate
optional
High Immediate
low addr
opcode
mod
high addr
reg
d w
r/m
optional
optional
optional
Low Immediate
optional
High Immediate
low addr
opcode
mod
high addr
reg
d w
r/m
optional
optional
optional
Low Immediate
optional
High Immediate
low addr
d w
opcode
mod
reg
high addr
r/m
optional
optional
optional
Low Immediate
optional
High Immediate
mov
ax, bx
100010
1
1
11
000
011
mov
destination is register
destination size = 1 word
this indicates that r/m specifies a register
destination register is ax
source register is bx
AX,
AX,
AX,
AX
BX
AX,
BX
BX
BX
BX
;AX
;AX
;AX
;AX
;BX
;AX
gets
gets
gets
gets
gets
gets
value AX+BX
value AX-BX
bitwise AND of AX and BX
its original value plus 1
its original value minus 1
values in BX
ASSEMBLER
01
29
21
40
4B
8B
D8
D8
D8
C3
LINKER
01
29
21
40
4B
8B
D8
D8
D8
C3
LOADER
93ee:db1e
93ee:db1f
93ee:db20
93ee:db21
93ee:db22
93ee:db23
93ee:db24
93ee:db25
93ee:db26
93ee:db27
01
D8
29
D8
21
D8
40
4B
8B
C3
logical
address
physical
memory
a19fe
a19ff
a1a00
a1a01
a1a02
a1a03
a1a04
a1a05
a1a06
a1a07
physical
address
Operand types
1) Register - Encoded in Instruction
Fastest Executing
No Bus Access (in Instr. Queue)
Short Instruction Length
2) Immediate - Constant Encoded in Instruction
8 or 16 bits
No Bus Access (in Instr. Queue)
Can only be Source Operand
3) Memory - Requires Bus Transfer
Can Require Computation of Address
Address of Operand DATA is Called
EFFECTIVE ADDRESS
Operand in Memory
1) Resident at an Address
Fastest Executing
No Bus Access (in Instr. Queue)
Short Instruction Length
2) Immediate - Constant Encoded in Instruction
8 or 16 bits
No Bus Access (in Instr. Queue)
Can only be Source Operand
3) Memory - Requires Bus Transfer
Can Require Computation of Address
Address of Operand DATA is Called
EFFECTIVE ADDRESS
Effective Address
Computed by EU
In General,
displacement + base register + index register
Addressing Modes
CLASSIFICATION I
Register/Register*
Immediate*
Direct
Register Indirect
Based
Indexed
Based Indexed
String
I/O Port
CLASSIFICATION II
Register/Register*
Immediate*
Direct
Indirect
Register Indirect
Based
Indexed
Based Indexed
String
I/O Port
Direct Addressing
mov
[7000h],
ax
ds:7000h
mov
ax
es:[7000h], ax
es:7000h
A3 00 70
26 A3 00 70
ax
prefix byte
- longer instruction
- more fetch time
opcode
mod r/m
displacement
effective address
al,
[bp]
mov
ah,
[bx]
mov
ax,
[di]
mov
eax, [si]
opcode
mod r/m
BX
BP
OR
effective address
SI
DI
mov
al,
[bp+2]
mov
ah,
[bx-4]
opcode
mod r/m
displacement
BX
BP
effective address
ax,
[di+1000h]
mov
eax,
[si+300h]
opcode
mod r/m
displacement
DI
SI
effective address
ax,
[bp+di]
mov
ax,
[di+bp]
mov
eax,
[bx+si+10h]
mov
cx,
opcode
mod r/m
displacement
DI
SI
BX
BP
effective address
bl
;8-bit register addressing
bp
;16-bit register addressing
eax
;32-bit register addressing
12
;8-bit immediate, al<-0ch
faceh
;16-bit immediate, cx<-64,206
2h
;32-bit immediate, ebx<-00000002h
LIST
;al<-8 bits stored at label LIST
DATA
;ch<-8 bits stored at label DATA
DATA2
;ds<-16 bits stored at label DATA2
[bp]
;al<-8 bits stored at SS:BP
[bx]
;ah<-8 bits stored at DS:BX
[bp]
;ax<-16 bits stored at SS:BP
[bx]
;eax<-32 bits stored at DS:BX
es:[bp]
;ax<-16 bits stored at SS:DI
[bp+2]
;al<-8 bits stored at SS:(BP+2)
[bx-4]
;ax<-16 bits stored at DS:(BX-4)
LIST[bp]
;al<-8 bits stored at SS:(BP+LIST)
LIST[bx]
;bx<-16 bits stored at DS:(BX+LIST)
LIST[bp+2] ;al<-8 bits stored at SS:(BP+2+LIST)
LIST[bx-12h] ;ax<-16 bits stored at DS:(BX-
Register
Immediate
Direct
Based
al,
ah,
ax,
eax,
ax,
al,
ax,
al,
bx,
al,
ax,
al,
ah,
ax,
eax,
al,
ax,
al,
ax,
[si]
;al<-8 bits stored at DS:SI
[di]
;ah<-8 bits stored at DS:DI
[si]
;ax<-16 bits stored at DS:SI
[di]
;eax<-32 bits stored at DS:DI
Indexed
es:[di]
;ax<-16 bits stored at ES:DI
[si+2]
;al<-8 bits stored at DS:(SI+2)
[di-4]
;ax<-16 bits stored at DS:(DI-4)
LIST[si]
;al<-8 bits stored at DS:(SI+LIST)
LIST[di]
;bx<-16 bits stored at DS:(DI+LIST)
LIST[si+2] ;al<-8 bits stored at DS:(SI+2+LIST)
LIST[di-12h] ;ax<-16 bits stored at DS:(DI-18+LIST)
[bp+di]
;al<-8 bits from SS:(BP+DI)
ds:[bp+si] ;ah<-8 bits from DS:(BP+SI)
Based
[bx+si]
;ax<-16 bits from DS:(BX+SI)
Indexed
es:[bx+di] ;eax<-32 bits from ES:(BX+DI)
LIST[bp+di] ;al<-8 bits from SS:(BP+DI+LIST)
LIST[bx+si] ;ax<-16 bits from DS:(BX+SI+LIST)
LIST[bp+di-10h]
;al<-8 bits from SS:(BP+DI-16+LIST)
LIST[bx+si+1AFH]
;ax<-16 bits from DS:(BX+SI+431+LIST)
String Addressing
Implicit Register Use
SI Used for Source EA
DI Used for Destination EA
;move a string
;compare two strings
;scan (search) string
;load a string
;store a string
String Addressing
movsb
mov
rep movsb
cld
std
rep
repe
repz
repne
repnz
al,
ax,
al,
eax,
80h,
dx,
40h
255
dx
dx
al
eax
CPU
Memory
I/O
Devices
Control Bus