# Free Electronic Circuits & 8085 projects

## Explanation of Instruction set of 8086 with free Sample Programs – Arithmetic Instructions1

Published on Oct 29 2009

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.

EXAMPLE:

ADC CL,BL                ;Add contents of BL plus carry status to contents of CL Results in CL
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
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.

Example:

; 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 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.

Example:

MOV AH,0            ;Clear AH for MSD
MOV AL,6            ;BCD 6 in AL
AAA                    ;AH=1, AL=1 representing BCD 11.