Flag Control instructions CLC clear carry flag CF = 0 STC set carry flag CF= 1 CMC complement carry flag [CF] CF
ADD action Add ADD D,S [S] + [D]] [D] [carry] [CF] flags affected: OF, SF, ZF, AF, PF, CF ADC action Add with carry ADC D,S [S] + [D] + [CF] [D] [carry] [CF] flags affected: OF, SF, ZF, AF, PF, CF Destination Source Register Register Register Memory Memory Register Register Immediate Memory Immediate Accumulator Immediate
DH
Format INC DAction[D+1] → [D] D R 16 R 8 M not in the debugger environment ! Flags affected SF, ZF,AF,PF
ADD immediate to accumulator WDataData if W= ADD AL,25H ADD AL, BL ADD Reg/Mem with Reg DWmod reg r/mDispl-lo C3 Displ-hi D8
Only 1 binary coded decimal digit is placed in 1 byte 2 binary coded decimal digits are packed in 1 byte Packed BCD Unpacked BCD
Assume that AL contains 32 H which is the ASCII code for 2 10 and BL contains 34 H which is the ASCII code for 4 10 and AH has been cleared. What is the result of executing the following instructions? ADD AL, BL AAA AAA = ASCII adjust after addition Note that the CF and AF remain cleared AX = 66 AX = 6 machine code Assume that AL contains 35 H which is the ASCII code for 5 10 and BL contains 37 H which is the ASCII code for 7 10 and AH has been cleared. What is the result of executing the following instructions? ADD AL, BL AAA AX = 6C AX = Note that CF and AF are set (Unpacked BCD)
Repeat assuming that AL contains 06 H and BL contains 04 H and AH has been cleared. What is the result of executing the following instructions? ADD AL, BL DAA DAA = decimal adjust after addition Assume that AL contains 08 H and BL contains 04 H and AH has been cleared. What is the result of executing the following instructions? ADD AL, BL DAA 0C 0012 (packed BCD) 0A 0010 (packed BCD)
SUB register/memory with register to either DW B05 SUB AX, [DI] MOV register/memory to/from register DWmod reg r/mDispl-lo Displ-hi MOV [SI], AX mod reg r/mDispl-loDispl-hi
MOV immediate to register 1011W regDataData if W= BE00 MOV SI, 200H MOV DI, 100H MOV register/memory to/from register DWmod reg r/mDispl-lo B04 Displ-hi BF 0001 MOV AX,[SI] MOV AX, [DI] B05
INC register reg INC SI INC DI SBB register/memory and register to either DWmod reg r/mDispl-lo B05 Displ-hi SBB AX,[DI]
MOV DS,AX MOV AX, 1000
BE BF B 04 2B B B EDS: EDS: DDS:200 EF EE EE EE Mov si,0200 Mov di,0100 Mov ax,[si] Sub ax,[di] Mov [si],ax Inc si Mov ax,[si] Inc di Sbb ax,[di] Mov [si],ax
Negate instruction : MOV AX,0060 NEG AX ’complement F F A 0
B328 B DW Subtract m/reg and reg to either Mod reg r/mDisp-loDisp-hi AC3 DAS decimal adjust after subtraction F
B83800 Subtract immediate from accumulator Wdatadata if W=1 2C39 AAS ASCII adjust for subtraction F
If AL=-1 and CL=-2 MUL CL If AL=-1 and CL=-2 IMUL CL AL=FF CL= FE Unsigned multiplication Result AX= FD02 Result AX= 2 Signed multiplication CF is set because there is a carry from the LSByte VF is set because the result cannot fit in 1 Byte
MOV BX,0009 MOV AX,0007 MUL BL AAM BCD Arithmetics AX=003F MOV AX, 0603 AAD AX=003F
Signed COMPARE example MOV AX, 99 AX= ( ) MOV BX, 1B BX= ( ) CMP AX, BX 2’scomplement [ ] = = = B 16 = – 27 = = 2’s complement [ ] = 2’s complement [ ] = = D AF=1 CF=0 OF=0