8 - Chapter 8 Arithmetic and Logic Instructions 1 Addition...

Info iconThis preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Chapter 8 Arithmetic and Logic Instructions
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 Addition The ADD instruction is used for binary addition. The addition causes the flag bits to change. Addition can be 8-, 16-, and 32-bits. All of the addressing modes are used by addition. ADD AL,BL ;AL=AL+BL ADD EAX,EBX ;EAX = EAX + EBX ADD CL, 44H ;CL=CL+44H
Background image of page 2
3 Addition • The program adds two consecutive bytes of data stored at the data segment offset address NUMB and NUMB+1 to the AL register. •DI= offset address of NUMB •[DI]= contents of the data segment memory location addressed by DI.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
4 Addition • The program adds the contents of array elements 3, 5 and 7 together.
Background image of page 4
5 Increment Addition The INC instruction adds a one to a register or the contents of a memory location. INC BX ;BX = BX + 1 INC SP ;SP=SP+1 INC DATA1 ;add 1 to the contents of data ;segment memory location ;DATA1
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
6 Addition with Carry The ADC instruction adds the carry bit into the sum. Used for wide additions (wider than 32- bits) and other reasons. ADD AX,CX ADC BX, DX ;BX=BX+DX+carry
Background image of page 6
7 BCD Addition- Decimal Adjust After Addition DAA instruction follows the ADD or ADC instruction to adjust the result into a BCD result. DAA functions only with AL register and addition must occur 8 bits at a time. MOV DX, 1234H ;load 1234 BCD MOV BX, 3099H ;load 3099 BCD MOV AL,BL ; AL=BL=99H; ADD AL,DL ; AL=AL+DL, DL=34H DAA MOV CL,AL ;answer to CL MOV AL, BH ;AL=BH, BH=30H ADC AL,DH ;AL=AL+DH+carry DAA MOV CH, AL ;answer to CH, CX=4333H This programme adds the BCD numbers in DX and BX and stores the result in CX.
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Subtraction The SUB instruction performs subtraction and the flags change to reflect condition of the result. As with other arithmetic and logic
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 30

8 - Chapter 8 Arithmetic and Logic Instructions 1 Addition...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online