Tải bản đầy đủ (.pdf) (8 trang)

Thiết kế và lập trình hệ thống - Chương 20

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (200.01 KB, 8 trang )

Systems Design & Programming 80x86 Assembly II CMPE 310
1 (Feb. 9, 2002)
UMBC
U M B C
U
N
I
V
E
R
S
I
T
Y


O
F


M
A
R
Y
L
A
N
D


B


A
L
T
I
M
O
R
E


C
O
U
N
T
Y
1

9

6

6
Data Addressing Modes
Base-Plus-Index addressing:
Effective address computed as:
seg_base + base + index.
Base registers: Holds starting location of an array.
• ebp (stack)
• ebx (data)

• Any 32-bit register except esp.
Index registers: Holds offset location.
• edi
• esi
• Any 32-bit register except esp.
mov dl, [eax+ebx]
;EAX as base, EBX as index.
mov ecx,[ebx+edi]
;Data segment copy.
mov ch, [ebp+esi]
;Stack segment copy.
Systems Design & Programming 80x86 Assembly II CMPE 310
2 (Feb. 9, 2002)
UMBC
U M B C
U
N
I
V
E
R
S
I
T
Y


O
F



M
A
R
Y
L
A
N
D


B
A
L
T
I
M
O
R
E


C
O
U
N
T
Y
1


9

6

6
Data Addressing Modes
Base-Plus-Index addressing:
eax
ebx
ecx
edx
esp
ebp
edi
esi
1 0 0 0
cs
ds
es
ss
A B 0 3
0 0 1 0
Memory
F012AB03
0 1 0 0
+
1010H
+
mov edx, [ebx+edi]
F 0 1 2

0 0 0 0
Seg
Base
Paging
Physical Address
Trans.
Systems Design & Programming 80x86 Assembly II CMPE 310
3 (Feb. 9, 2002)
UMBC
U M B C
U
N
I
V
E
R
S
I
T
Y


O
F


M
A
R
Y

L
A
N
D


B
A
L
T
I
M
O
R
E


C
O
U
N
T
Y
1

9

6

6

Data Addressing Modes
Register Relative addressing:
Effective address computed as:
seg_base + base + constant.
Same default segment rules apply with respect to ebp, ebx, edi and esi.
Displacement constant is any 32-bit signed value.
Base Relative-Plus-Index addressing:
Effective address computed as:
seg_base + base + index + constant.
Designed to be used as a mechanism to address a two-dimensional array.
mov edx, [LIST+esi+2]
;Both LIST and 2 are constants.
mov eax, [ebx+1000H]
;Data segment copy.
mov [ARRAY+esi], BL
;Constant is ARRAY.
mov edx, [LIST+esi-2]
;Subtraction.
mov [LIST+ebp+esi+4], dh
;Stack segment copy.
mov dh, [ebx+edi+20H]
;Data segment copy.
mov ax, [FILE+ebx+edi]
;Constant is FILE.
mov eax, [FILE+ebx+ecx+2]
;32-bit transfer.
Systems Design & Programming 80x86 Assembly II CMPE 310
4 (Feb. 9, 2002)
UMBC
U M B C

U
N
I
V
E
R
S
I
T
Y


O
F


M
A
R
Y
L
A
N
D


B
A
L
T

I
M
O
R
E


C
O
U
N
T
Y
1

9

6

6
Data Addressing Modes
Base Relative-Plus-Index addressing:
0 0 2 0
A 3 1 6
0 0 1 0
Memory
A316
1 0 0 0
+
+

MOV ax, [ebx+esi+100H]
+
100H
0 0 0 0
eax
ebx
ecx
edx
esp
ebp
edi
esi
cs
ds
es
ss
Seg
Base
Paging
Trans.
1030H
Systems Design & Programming 80x86 Assembly II CMPE 310
5 (Feb. 9, 2002)
UMBC
U M B C
U
N
I
V
E

R
S
I
T
Y


O
F


M
A
R
Y
L
A
N
D


B
A
L
T
I
M
O
R
E



C
O
U
N
T
Y
1

9

6

6
Data/Code Addressing Modes
Scaled-Index addressing:
Effective address computed as:
seg_base + base + constant*index.
Code Memory-Addressing Modes:
Used in jmp and call instructions.
Three forms:
Direct
PC-Relative
Indirect
Direct:
Absolute jump address is stored in the instruction following the
opcode.
mov eax, [ebx+4*ecx]
;Data segment DWORD copy.

;Whow !
mov eax, [ARRAY+4*ecx]
;Std array addressing.
mov [eax+2*edi-100H], cx

×