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

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

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 (661.32 KB, 11 trang )

Systems Design & Programming 80x86 Assembly IV CMPE 310
1 (Mar. 1, 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
Intel Assembly
Systems Design & Programming 80x86 Assembly IV CMPE 310
2 (Mar. 1, 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
Arithmetic Operations
add al, [ARRAY + esi]
;Adds 1 to any reg/mem except seginc byte [edi]
;Adds registers + Carry flag.
adc ecx, ebx
;ecx=ecx+ebx, ebx=original ecx.
xadd ecx, ebx
;Used for adding 64 bit nums.
Systems Design & Programming 80x86 Assembly IV CMPE 310
3 (Mar. 1, 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
Arithmetic Operations
sub eax, ebx
dec edi
;Subs registers - Carry flag.
sbb ecx, ebx
;eax=eax-ebx
cmp al, 10H
jae LABEL1
;Jump if equal or below.
jbe LABEL2

;if ecx==eax, eax=edx else eax=ecx
cmpxchg ecx, edx
;Jump if equal or above.
Systems Design & Programming 80x86 Assembly IV CMPE 310
4 (Mar. 1, 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
Arithmetic Operations
mul bl
imul bx

;Special, cx=dx*12H (signed only)
imul cx, dx, 12H
;edx|eax=eax*ecx
mul ecx
;ax=al*bl (unsigned)
;dx|ax=ax*bx (signed)
div cl
;dx|ax=(dx|ax)/cx
idiv cx
;ah|al=ax/cl, unsigned quotient
; in al, remainder in ah
Systems Design & Programming 80x86 Assembly IV CMPE 310
5 (Mar. 1, 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
Logic Operations
XXXX XXXX Operand
0000 1111 Mask
0000 XXXX Result
and al, bl ;al=al AND bl
XXXX XXXX Operand
0000 1111 Mask
XXXX 1111 Result
or eax, 10 ;eax=eax OR 0000000AH

×