1 / 10

Arithmetic and Logic Instructions First and Third Group

Arithmetic and Logic Instructions First and Third Group. أعداد: م.م. سمر أميل يوسف. First Group Instruction. ADD , SUB,CMP, AND, TEST, OR, XOR REG , memory memory , REG REG , REG memory , immediate REG , immediate These instructions affect these flags only:

mcilvain
Download Presentation

Arithmetic and Logic Instructions First and Third Group

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. Arithmetic and Logic Instructions First and Third Group أعداد: م.م. سمر أميل يوسف

  2. First Group Instruction ADD, SUB,CMP, AND, TEST, OR, XOR REG, memory memory, REG REG, REG memory, immediate REG, immediate These instructions affect these flags only: CF, ZF, SF, OF, PF, AF.

  3. First Group Instruction CMP - Subtract second operand from first for flags only. MOV AX,5555H MOV [BX], 2222H CMP [BX],AX CMP AX,[BX] CMP [BX],1111H

  4. First Group Instruction AND - Logical AND between all bits of two operands. The rules apply: 1 AND 1 = 1 1 AND 0 = 0 0 AND 1 = 0 0 AND 0 = 0 As you see we get 1 only when both bits are 1. MOV AX,1111H MOV BX ,0FFFH ; try 0000H AND AX,BX RET

  5. First Group Instruction TEST - The same as AND but for flags only. MOV AX,1111H TEST AX,BX RET

  6. First Group Instruction OR - Logical OR between all bits of two operands. The rules apply: 1 OR 1 = 1 1 OR 0 = 1 0 OR 1 = 1 0 OR 0 = 0 As you see we get 1 every time when at least one of the bits is 1. MOV BX,1111H OR AX,BX RET

  7. First Group Instruction XOR - Logical XOR (exclusive OR) between all bits of two operands. The rules apply: 1 XOR 1 = 0 1 XOR 0 = 1 0 XOR 1 = 1 0 XOR 0 = 0 As you see we get 1 every time when bits are different from each other. MOV BX,0101H MOV AX,1111H XOR AX,BX RET

  8. Third Group Instructions INC, DEC, NOT, NEG REG Memory • INC, DEC instructions affect these flags only: ZF, SF, OF, PF, AF. • NOT instruction does not affect any flags! • NEG instruction affects these flags only: CF, ZF, SF, OF, PF, AF.

  9. Third Group Instructions The NOT instruction inverts each bit (forms the 1’s complement) of a byte or word in the specified destination. The destination can be a register or a memory location. This instruction does not affect any flag. NOT AX NOT CL NOT [BX] RET

  10. Third Group Instructions The NEG instruction replaces the number in a destination with its 2’s complement. The destination can be a register or a memory location. It gives the same result as the invert each bit and add one algorithm. MOV AX,10100110b NEG AX RET

More Related