CF? 1 - PowerPoint PPT Presentation

1 / 7
About This Presentation
Title:

CF? 1

Description:

4.2 Arithmetic Instructions Addition instructions: ADD, ADC, INC ,AAA, DAA ADD, ADC INC CF 0 AF 1 Initial AL: 0110 1001+ Initial BL: 0100 1000 – PowerPoint PPT presentation

Number of Views:83
Avg rating:3.0/5.0
Slides: 8
Provided by: EECS73
Learn more at: http://www.eecs.wsu.edu
Category:

less

Transcript and Presenter's Notes

Title: CF? 1


1
4.2 Arithmetic Instructions
Addition instructions ADD, ADC, INC ,AAA, DAA
CF? 0
AF?1
Initial AL 0110 1001
Initial BL 0100 1000
Because 1011gt1001 AF1

AL after ADD 1011 0001
DAA 0110 0110
CF? 1
AL after DAA 0001 0111
AF?1
ADD AL, BL
AL after clear 0000 0000
Example BCD addition
CF? 0
DAA
supposing BH29H BL48H AL69H
Initial BH 0010 1001
AF? 0
MOV BL, AL
Carry Flag 1
MOV AL, 0
Because CF0,0010lt1001 1010gt1001

2948 69
AL after ADC 0010 1010
ADC AL, BH
DAA 0000 0110
DAA
AL after DAA 0011 0000
MOV BH, AL
3017
2
4.2 Arithmetic Instructions
Subtraction instructions SUB, SBB, DEC, NEG,
AAS, DAS
SF? 1
CF? 1
AF?1
Initial AL 0100 1000-
Initial BL 0110 1001
Because CF,1101gt1001 AF,1111gt1001
-
AL after SUB 1101 1111
DAS 0110 0110
CF? 1
AL after DAS 0111 1001
AF? 1
SUB AL, BL
AL after update 0010 1001-
Example BCD addition
CF? 0
DAS
supposing AH29H AL48H BL69H
Subtractor 0000 0000
AF? 0
MOV BL, AL
Carry Flag 1
MOV AL, AH
Because CF0,0010lt1001 AF0,1000lt100
1
-
2948- 69
AL after SBB 0010 1000
SBB AL, 0
DAS 0000 0000
DAS
AL after DAS 0010 1000
MOV BH, AL
2879
3
4.2 Arithmetic Instructions
Multiplication instructions MUL, IMUL, AAM
MUL, IMUL
IMUL additional, 2 operands
Examples signed and unsigned multiplication
supposing AL FFH -1(2sC) CL FEH -2(2sC)
AAM
IMUL additional, 3 operands
IMUL CL
MUL CL
AX?FD02H
AX?0002H
4
4.2 Arithmetic Instructions
Division and conversion instructions DIV, IDIV,
AAD, CBW, CWD
DIV, IDIV
AAD
CBW
CWD
CWD
CWDE
Examples multiplying AL by CX (signed values)
supposing AL FFH -1(2sC) CX FFFEH
-2(2sC)
Convert byte FFH to word FFFFH in AX
CBW
IMUL CX
Multiplying words AX and CX
5
4.3 Logical Instructions
AND, OR, XOR, TEST, NOT
Examples difference between AND and TEST
supposing AL 25H 0010 0101B CL 55H 0101
0101B
TEST AL,CL
AND AL,CL
AL?05H0000 0101B SF?0 ZF?0 PF?1
AL?25H0010 0101B SF?0 ZF?0 PF?1
BSF, BSR
supposing EAX 0000 0000 0111 1111 0000 0000
0000 0000B
BSF, BSR
BSF EBX, EAX
BSR EBX, EAX
EBX ?10H
EBX ?16H
6
4.3 Logical Instructions
BT, BTC, BTS, BTR
BT, BTC, BTS, BTR
Example MOV AX,5555H AX5555,CF0 BT AX,10 AX
5555,CF1 BT AX,11 AX5555,CF0 MOV BX,10 BTC
AX,BX AX5155,CF1 INC BX BTS AX,BX AX5955,CF
0 BTR AX,0 AX5554,CF1
7
4.3 Logical Instructions
SETcc
The terms less and greater are used for
comparisons of signed integers.
The terms above and below are used for
comparisons of unsigned integers.
Write a Comment
User Comments (0)
About PowerShow.com