Presentation is loading. Please wait.

Presentation is loading. Please wait.

ADDITION Register Addition. ADD AX,BX AX=AX+BX 2. Immediate Addition.

Similar presentations


Presentation on theme: "ADDITION Register Addition. ADD AX,BX AX=AX+BX 2. Immediate Addition."— Presentation transcript:

1 ADDITION Register Addition. ADD AX,BX AX=AX+BX 2. Immediate Addition.
ADD BL,76H BL=BL+76H 3. Memory-to Register addition. ADD [BX+DI],DL [BX+DI]=[BX+DI]+DL Array Addition. ADD AL,ARRAY[SI] AL=AL+ARRAY[SI]

2 Increment Addition. INC CX CX=CX+1 INC WORD PTR[SI] INC [DI] 6. Addition-with Carry. ADC AL,BL AL= AL + BL+ carry 7. Exchange and Add (80486-Pentium 4) XADD BL,AL BL=BL+AL , AL=BL

3 SUBTRACTION Register Subtraction. SUB BL,DL BL=BL-DL
Immediate Subtraction. SUB BH,76H BH=BH-76H Decrement Subtraction. DEC BL BL=BL-1 DEC DWORD PTR[EBP] DEC [DI] Subtraction-with-Borrow. SBB AX,BX AX=AX-BX-Borrow

4 COMPARISON CMP DX,AX DX-AX Flag Changed
CMP BX,1234H BX-1234H Flag Changed CMP CL,[BP] CL-[BP] Flag Changed Compare and Exchange (80486-Pentium 4). CMPXCHG CX,DX if CX=AX AX=DX if CX≠AX AX=CX

5 MULTIPLICATION AND DIVISION
8-bit Multiplication. MUL DL AX=AL*DL Unsigned IMUL CH AX=AL*CH Signed 16-bit Multiplication. MUL CX (DX-AX)=AX*CX Unsigned IMUL SI (DX-AX)=AX*SI Signed 32-bit Multiplication. MUL ECX (EDX-EAX)=EAX*ECX Unsigned IMUL ESI (EDX-EAX)=EAX*ESI Signed

6 DIVISION IDIV BL AL=S-quotient( AX/BL) 8-bit Division.
DIV CL AL=Uns-quotient( AX/CL) AH=Uns-remainder( AX/CL) IDIV BL AL=S-quotient( AX/BL) AH=S-remainder( AX/BL) 2. 16-bit Division. DIV CX AX=Uns-quotient( DX-AX/CX) DX=Uns-remainder( DX-AX/CX) IDIV SI AX=S-quotient( DX-AX/CX) DX=S-remainder( DX-AX/CX) bit Division. DIV ECX EAX=Uns-quotient (EDX-EAX/ECX) EDX=Uns-remainder( EDX-EAX/ECX) IDIV DATA EAX=S-quotient (EDX-EAX/[DATA]) EDX=S-remainder( EDX-EAX/[DATA])

7 BCD and ARITHMETIC BCD Arithmetic.
DAA (decimal adjust after addition). MOV BX,1234H MOV DX,5678H MOV AL,BL ADD AL,DL DAA (adjustment function only with the AL) DAS (decimal adjust after subtraction) SUB AL,DL DAS (adjustment function only with the AL)

8 ASCII Arithmetic. Function with ASCII-coded numbers (30H-39H) AAA (ASCII adjust after addition) MOV AX,31H ADD AL,39H AAA if result<10 AH=0,if greater AH=AH+1 ADD AX,3030H AAD (ASCII adjust before division) MOV BL,9 MOV AX,702H AAD convert the unpacked BCD (00-99) into binary DIV BL

9 AAM (ASCII adjust after multiplication)
MOV AL,5 MOV CL,5 MUL CL AAM AL=reminder(AX/10), AH=quotient(AX/10) AAS (ASCII adjust after subtraction) MOV AX,39H SUB AL,33H AAS

10 BASIC LOGIC INSTRUCTIONS
AND. AND AX,BX AX=AX and BX OR. OR AL,BH AL=AL or BH EXCLUSIVE-OR. XOR CH,DL CH=CH xor DL

11 4. Test and Bit Test Instructions. TEST DL,DH DL and DH
BT BX, tests a bit position 3, carry=b2 BTC AX, tests a bit position 4, carry=b3, b3=b3 BTR DX,2 test a bit position 2, carry=b1, b1=0 BTS CX,13 test a bit position 13, carry=b12, b12=1 5. NOT and NEG. NOT CL CL=CL NEG CL CL=CL +1

12 SHIFT and ROTATE Shift. SHL AX,1 SAL BX,1 SHR ECX,14 SAR SI,CL
D-P-SH (80386-P4) SHRD AX,BX,10 SHLD EBX,ECX,18 C SHL SAL SHR SAR

13 Rotate. RCL AL,1 ROL EDX,20 RCR AH,CL ROR WORD PTR[BP],4
Bit Scan Instructions (80386-P4) BSF EBX,EAX BSR EBX,EAX C RCL ROL RCR ROR

14 STRING COMPARISONS String scan instruction.
compares the AL register with a byte block of memory, the AX with a word block of memory or the EAX with a doubleword block of memory. SCASB AL-ES:[DI] DI=DI±1 SCASW AX-ES:[DI] DI=DI±2 SACSD EAX-ES:[DI] DI=DI±4 Compare strings instruction. compares two sections of memory data as byte, word, doubleword. CMPSB DS:[SI] -ES:[DI] SI=SI±1,DI=DI±1 CMPSW DS:[SI] -ES:[DI] SI=SI±2,DI=DI±2 CMPSD DS:[SI] -ES:[DI] SI=SI±4,DI=DI±4


Download ppt "ADDITION Register Addition. ADD AX,BX AX=AX+BX 2. Immediate Addition."

Similar presentations


Ads by Google