Presentation is loading. Please wait.

Presentation is loading. Please wait.

Flag Control instructions CLC clear carry flag CF = 0 STC set carry flag CF= 1 CMC complement carry flag [CF] CF.

Similar presentations


Presentation on theme: "Flag Control instructions CLC clear carry flag CF = 0 STC set carry flag CF= 1 CMC complement carry flag [CF] CF."— Presentation transcript:

1 Flag Control instructions CLC clear carry flag CF = 0 STC set carry flag CF= 1 CMC complement carry flag [CF] CF

2 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

3 DH

4 Format INC DAction[D+1] → [D] D R 16 R 8 M not in the debugger environment ! Flags affected SF, ZF,AF,PF

5 ADD immediate to accumulator 0000010WDataData if W=1 0000010000100101 0425 ADD AL,25H ADD AL, BL ADD Reg/Mem with Reg 000000DWmod reg r/mDispl-lo 0000001011000011 02C3 Displ-hi 0000000011011000 00D8

6 Only 1 binary coded decimal digit is placed in 1 byte 2 binary coded decimal digits are packed in 1 byte Packed BCD 56 10 0101 0110 Unpacked BCD 56 10 0000 0101 00000110

7

8 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 00110110 36 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 = 01 02 Note that CF and AF are set (Unpacked BCD)

9 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 00100111 27 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)

10

11 SUB register/memory with register to either 001010DW 00101011 00000101 2B05 SUB AX, [DI] MOV register/memory to/from register 100010DWmod reg r/mDispl-lo 1000100100000100 8904 Displ-hi MOV [SI], AX mod reg r/mDispl-loDispl-hi

12 MOV immediate to register 1011W regDataData if W=1 10111110 00000000 BE00 MOV SI, 200H MOV DI, 100H MOV register/memory to/from register 100010DWmod reg r/mDispl-lo 1000101100000100 8B04 Displ-hi 00000010 02 10111111 0000000000000001 BF 0001 MOV AX,[SI] MOV AX, [DI]1000101100000101 8B05

13 INC register 01000 reg INC SI 01000110 46 INC DI 01000111 47 SBB register/memory and register to either 000110DWmod reg r/mDispl-lo 0001101100000101 1B05 Displ-hi SBB AX,[DI]

14 MOV DS,AX MOV AX, 1000

15 BE 00 02 BF 00 01 8B 04 2B 05 89 04 46 8B 04 47 1B 05 89 04 EDS:200 78 56 34 12 EDS:100 89 67 45 23 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

16 Negate instruction : MOV AX,0060 NEG AX 0000 0000 0110 0000 1111 1111 1010 00002’complement F F A 0

17 B328 B083 001010DW Subtract m/reg and reg to either Mod reg r/mDisp-loDisp-hi 00101010 11000011 2AC3 DAS decimal adjust after subtraction 00101111 2F

18 B83800 Subtract immediate from accumulator 0010110Wdatadata if W=1 2C39 AAS ASCII adjust for subtraction 00111111 3F

19

20 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

21 MOV BX,0009 MOV AX,0007 MUL BL AAM BCD Arithmetics AX=003F MOV AX, 0603 AAD AX=003F

22

23 Signed COMPARE example MOV AX, 99 AX=1001 1001 (-103 10 ) MOV BX, 1B BX=0001 1011 (+27 10 ) CMP AX, BX 2’scomplement [1001 1001] = 0110 0111 2 = 67 16 = - 103 10 1B 16 = 27 10 -103 – 27 = -130 10 = 2’s complement [ 28 16 ] = 2’s complement [ 0010 1000] = 1101 1000 2 = D8 16 1001 1001 - 0001 1011 0111 1110 AF=1 CF=0 OF=0

24

25


Download ppt "Flag Control instructions CLC clear carry flag CF = 0 STC set carry flag CF= 1 CMC complement carry flag [CF] CF."

Similar presentations


Ads by Google