- ADD Instruction – ADD destination, source
These instructions add a number from source to a number from some destination and put the result in the specified destination. The source and destination must be of same type , means they must be a byte location or a word location. If you want to add a byte to a word, you must copy the byte to a word location and fill the upper byte of the word with zeroes before adding.
ADC Instruction – Add with carry
After performing the addition, the add with carry instruction ADC, adds the status of the carry flag into the result.
ADD AL,74H ;Add immediate number 74H to content of AL
ADC CL,BL ;Add contents of BL plus carry status to contents of CL Results in CL
ADD DX, BX ;Add contents of BX to contents of DX
ADD DX, [SI] ;Add word from memory at offset [SI] in DS to contents of DX
; Addition of Un Signed numbers
ADD CL, BL ;CL = 01110011 =115 decimal + BL = 01001111 = 79 decimal Result in CL = 11000010 = 194 decimal
; Addition of Signed numbers
ADD CL, BL ;CL = 01110011 = + 115 decimal + BL = 01001111 = +79 decimal Result in CL = 11000010 = – 62 decimal
; Incorrect because result is too large to fit in 7 bits.
INC Instruction – Increment – INC destination
INC instruction adds one to the operand and sets the flag according to the result. INC instruction is treated as an unsigned binary number.
; AX = 7FFFh
INC AX ;After this instruction AX = 8000h
INC BL ; Add 1 to the contents of BL register
INC CL ; Add 1 to the contents of CX register.
AAA Instruction – ASCII Adjust after Addition
AAA converts the result of the addition of two valid unpacked BCD digits to a valid 2-digit BCD number and takes the AL register as its implicit operand.
Two operands of the addition must have its lower 4 bits contain a number in the range from 0-9.The AAA instruction then adjust AL so that it contains a correct BCD digit. If the addition produce carry (AF=1), the AH register is incremented and the carry CF and auxiliary carry AF flags are set to 1. If the addition did not produce a decimal carry, CF and AF are cleared to 0 and AH is not altered. In both cases the higher 4 bits of AL are cleared to 0.
AAA will adjust the result of the two ASCII characters that were in the range from 30h (“0”) to 39h(“9”).This is because the lower 4 bits of those character fall in the range of 0-9.The result of addition is not a ASCII character but it is a BCD digit.
MOV AH,0 ;Clear AH for MSD
MOV AL,6 ;BCD 6 in AL
ADD AL,5 ;Add BCD 5 to digit in AL
AAA ;AH=1, AL=1 representing BCD 11.
DAA Instruction – Decimal Adjust after Addition
The contents after addition are changed from a binary value to two 4-bit binary coded decimal (BCD) digits. S, Z, AC, P, CY flags are altered to reflect the results of the operation.
If the value of the low-order 4-bits in the accumulator is greater than 9 or if AC flag is set, the instruction adds 6 to the low-order four bits.
If the value of the high-order 4-bits in the accumulator is greater than 9 or if the Carry flag is set, the instruction adds 6 to the high-order four bits.
MOV AL, 0Fh ; AL = 0Fh (15)
DAA ; AL = 15h