Download presentation
Presentation is loading. Please wait.
1
4.2 Arithmetic Instructions
Addition instructions: ADD, ADC, INC ,AAA, DAA ADD, ADC INC CF 0 Initial AL: AF1 Initial BL: Because: 1011>1001 AF=1 AL after ADD: + AAA,DAA DAA: CF 1 AL after DAA: AF1 Example: BCD addition: ADD AL, BL AL after clear: CF 0 supposing: BH=29H BL=48H AL=69H DAA Initial BH: AF 0 MOV BL, AL Carry Flag: MOV AL, 0 Because: CF=0,0010<1001 1010>1001 2948+ 69 + ADC AL, BH AL after ADC: DAA DAA: 3017 MOV BH, AL AL after DAA:
2
4.2 Arithmetic Instructions
Subtraction instructions: SUB, SBB, DEC, NEG, AAS, DAS SUB, SBB, CMP SF 1 DEC, NEG CF 1 Initial AL: AF1 Initial BL: Because: CF,1101>1001 AF,1111>1001 AL after SUB: - AAS,DAS DAS: CF 1 AL after DAS: AF 1 Example: BCD addition: SUB AL, BL AL after update: CF 0 supposing: AH=29H AL=48H BL=69H DAS Subtractor: AF 0 MOV BL, AL Carry Flag: MOV AL, AH Because: CF=0,0010<1001 AF=0,1000<1001 2948- 69 - SBB AL, 0 AL after SBB: DAS DAS: 2879 MOV BH, AL AL after DAS:
3
4.2 Arithmetic Instructions
Multiplication instructions: MUL, IMUL, AAM MUL, IMUL IMUL additional, 2 operands Examples: signed and unsigned multiplication: AAM supposing: AL = FFH = -1(2’sC) CL = FEH = -2(2’sC) IMUL additional, 3 operands MUL CL IMUL CL AXFD02H AX0002H
4
4.2 Arithmetic Instructions
Division and conversion instructions: DIV, IDIV, AAD, CBW, CWD DIV, IDIV CBW AAD CWD CWD CWDE Examples: multiplying AL by CX (signed values): supposing: AL = FFH = -1(2’sC) CX = FFFEH = -2(2’sC) CBW Convert byte FFH to word FFFFH in AX IMUL CX Multiplying words AX and CX
5
4.3 Logical Instructions AND, OR, XOR, TEST, NOT BSF, BSR Examples:
difference between AND and TEST: AND, OR, XOR, TEST NOT supposing: AL = 25H = B CL = 55H = B AND AL,CL TEST AL,CL AL05H= B SF0; ZF0; PF1; AL25H= B SF0; ZF0; PF1; BSF, BSR supposing: EAX = B 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 ;AX=5555,CF=0 BT AX,10 ;AX=5555,CF=1 BT AX,11 ;AX=5555,CF=0 MOV BX,10 BTC AX,BX ;AX=5155,CF=1 INC BX BTS AX,BX ;AX=5955,CF=0 BTR AX,0 ;AX=5554,CF=1
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.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.