1 / 25

Flag Control instructions CLC clear carry flag CF = 0 STC set carry flag CF= 1

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]

chung
Download Presentation

Flag Control instructions CLC clear carry flag CF = 0 STC set carry flag CF= 1

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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 DestinationSource Register Register Register Memory Memory Register Register Immediate Memory Immediate Accumulator Immediate

  3. DH

  4. INC D Action [D+1] → [D] Format Flags affected SF, ZF ,AF ,PF D R16 R8 M not in the debugger environment !

  5. ADD AL,25H ADD immediate to accumulator 0000010W Data Data if W=1 00000100 00100101 04 25 ADD AL, BL ADD Reg/Mem with Reg 000000DW mod reg r/m Displ-lo Displ-hi 00000010 11000011 02 C3 00000000 11011000 00 D8

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

  7. Assume that AL contains 32H which is the ASCII code for 210 and BL contains 34H which is the ASCII code for 410 and AH has been cleared. What is the result of executing the following instructions? ADD AL, BL AAA AX = 66 AX = 6 AAA = ASCII adjust after addition 00110110 36 machine code Note that the CF and AF remain cleared Assume that AL contains 35H which is the ASCII code for 510 and BL contains 37H which is the ASCII code for 710 and AH has been cleared. What is the result of executing the following instructions? ADD AL, BL AAA AX = 6C (Unpacked BCD) AX = 01 02 Note that CF and AF are set

  8. Assume that AL contains 08H and BL contains 04H and AH has been cleared. What is the result of executing the following instructions? ADD AL, BL DAA 0C 0012 (packed BCD) 00100111 DAA = decimal adjust after addition 27 Repeat assuming that AL contains 06H and BL contains 04H and AH has been cleared. What is the result of executing the following instructions? ADD AL, BL DAA 0A 0010 (packed BCD)

  9. SUB AX, [DI] SUB register/memory with register to either 001010DW mod reg r/m Displ-lo Displ-hi 00000101 00101011 2B 05 MOV [SI], AX MOV register/memory to/from register 100010DW mod reg r/m Displ-lo Displ-hi 10001001 00000100 89 04

  10. MOV SI, 200H MOV immediate to register 1011W reg Data Data if W=1 00000010 00000000 10111110 BE 00 02 MOV DI, 100H 00000000 00000001 10111111 00 01 BF MOV AX,[SI] MOV register/memory to/from register 100010DW mod reg r/m Displ-lo Displ-hi 10001011 00000100 8B 04 MOV AX, [DI] 10001011 00000101 8B 05

  11. INC SI 01000 reg INC register 01000110 46 INC DI 01000111 47 SBB AX,[DI] SBB register/memory and register to either 000110DW mod reg r/m Displ-lo Displ-hi 00011011 00000101 1B 05

  12. MOV AX, 1000 MOVDS,AX

  13. BE 00 02 BF 00 01 8B 04 2B 05 89 04 46 46 8B 04 47 47 1B 05 89 04 Mov si,0200 Mov di,0100 Mov ax,[si] Sub ax,[di] Mov [si],ax Inc si Inc si Mov ax,[si] Inc di Inc di Sbb ax,[di] Mov [si],ax EDS:200 78 56 34 12 EDS:100 89 67 45 23 DDS:200 EF EE EE EE

  14. Negate instruction: MOV AX,0060 NEG AX 0000 0000 0110 0000 1111 1111 1010 0000 2’complement F F A 0

  15. B328 B083 Subtract m/reg and reg to either 001010DW Mod reg r/m Disp-lo Disp-hi 11000011 00101010 2A C3 DAS decimal adjust after subtraction 00101111 2F

  16. B83800 Subtract immediate from accumulator 0010110W data data if W=1 2C 39 AAS ASCII adjust for subtraction 00111111 3F

  17. If AL=-1 and CL=-2 MUL CL Result AX= FD02 AL=FF CL= FE Unsigned multiplication CF is set because there is a carry from the LSByte VF is set because the result cannot fit in 1 Byte If AL=-1 and CL=-2 IMUL CL Result AX= 2 Signed multiplication

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

  19. Signed COMPARE example MOV AX, 99 AX=1001 1001 (-10310) MOV BX, 1B BX=0001 1011 (+2710) CMP AX, BX 2’scomplement [1001 1001] = 0110 01112 = 6716 = - 10310 1B16 = 2710 -103 – 27 = -13010 = 2’s complement [ 2816] = 2’s complement [ 0010 1000] = 1101 10002 = D816 1001 1001 - 0001 1011 0111 1110 AF=1 CF=0 OF=0

More Related