Arithmetic Instructions:

The 8086 provides many arithmetic operations: addition, subtraction, negation,
multiplication and comparing two values.

ADD :
The add instruction adds the contents of the source operand to the destination
operand.
Eg. ADD AX, 0100H
ADD AX, BX
ADD AX, [SI]
ADD AX, [5000H]
ADD [5000H], 0100H
ADD 0100H

ADC : Add with Carry
This instruction performs the same operation as ADD instruction, but adds the carry
flag to the result.
Eg. ADC 0100H
ADC AX, BX
ADC AX, [SI]
ADC AX, [5000]
ADC [5000], 0100H

SUB : Subtract
The subtract instruction subtracts the source operand from the destination operand
and the result is left in the destination operand.
Eg. SUB AX, 0100H
SUB AX, BX
SUB AX, [5000H]
SUB [5000H], 0100H

SBB : Subtract with Borrow
The subtract with borrow instruction subtracts the source operand and the borrow flag
(CF) which may reflect the result of the previous calculations, from the destination
operand
Eg. SBB AX, 0100H
SBB AX, BX
SBB AX, [5000H]
SBB [5000H], 0100H

INC : Increment
This instruction increases the contents of the specified Register or memory location
by 1. Immediate data cannot be operand of this instruction.
Eg. INC AX
INC [BX]
INC [5000H]

DEC : Decrement
The decrement instruction subtracts 1 from the contents of the specified register or
memory location.
Eg. DEC AX
DEC [5000H]

NEG : Negate
The negate instruction forms 2’s complement of the specified destination in the
instruction. The destination can be a register or a memory location. This instruction can
be implemented by inverting each bit and adding 1 to it.
Eg. NEG AL
AL = 0011 0101 35H Replace number in AL with its 2’s complement
AL = 1100 1011 = CBH

CMP : Compare
This instruction compares the source operand, which may be a register or an
immediate data or a memory location, with a destination operand that may be a register or a memory location
Eg. CMP BX, 0100H
CMP AX, 0100H
CMP [5000H], 0100H
CMP BX, [SI]
CMP BX, CX

MUL :Unsigned Multiplication Byte or Word
This instruction multiplies an unsigned byte or word by the contents of AL.
Eg.
MUL BH                     ; (AX)        (AL) x (BH)
MUL CX                     ; (DX)(AX) (AX) x (CX)
MUL WORD PTR [SI] ; (DX)(AX) (AX) x ([SI])

IMUL :Signed Multiplication
This instruction multiplies a signed byte in source operand by a signed byte in AL or
a signed word in source operand by a signed word in AX.
Eg. IMUL BH
IMUL CX
IMUL [SI]

CBW : Convert Signed Byte to Word
This instruction copies the sign of a byte in AL to all the bits in AH. AH is then said
to be sign extension of AL.
Eg. CBW
AX= 0000 0000 1001 1000 Convert signed byte in AL signed word in AX.
Result in AX = 1111 1111 1001 1000

CWD : Convert Signed Word to Double Word
This instruction copies the sign of a byte in AL to all the bits in AH. AH is then said
to be sign extension of AL.
Eg. CWD
Convert signed word in AX to signed double word in DX : AX
DX= 1111 1111 1111 1111
Result in AX = 1111 0000 1100 0001

DIV : Unsigned division
This instruction is used to divide an unsigned word by a byte or to divide an unsigned
double word by a word.
Eg.
DIV CL ; Word in AX / byte in CL
            ; Quotient in AL, remainder in AH
DIV CX ; Double word in DX and AX / word
            ; in CX, and Quotient in AX,
            ; remainder in DX

AAA : ASCII Adjust After Addition
The AAA instruction is executed after an ADD instruction that adds two ASCII coded
operand to give a byte of result in AL. The AAA instruction converts the resulting
contents of Al to a unpacked decimal digits.
Eg.
ADD CL, DL ; [CL] = 32H = ASCII for 2
                    ; [DL] = 35H = ASCII for 5
                    ; Result [CL] = 67H
MOV AL, CL ; Move ASCII result into AL since
                    ; AAA adjust only [AL]
AAA             ; [AL]=07, unpacked BCD for 7

AAS : ASCII Adjust AL after Subtraction
This instruction corrects the result in AL register after subtracting two unpacked
ASCII operands. The result is in unpacked decimal format. The procedure is similar to
AAA instruction except for the subtraction of 06 from AL.

AAM : ASCII Adjust after Multiplication
This instruction, after execution, converts the product available In AL into unpacked
BCD format.
Eg.
MOV AL, 04 ; AL = 04
MOV BL ,09 ; BL = 09
MUL BL        ; AX = AL*BL ; AX=24H
AAM             ; AH = 03, AL=06

AAD : ASCII Adjust before Division
This instruction converts two unpacked BCD digits in AH and AL to the equivalent
binary number in AL. This adjustment must be made before dividing the two unpacked
BCD digits in AX by an unpacked BCD byte. In the instruction sequence, this
instruction appears Before DIV instruction.
Eg.
AX 05 08
AAD result in AL 00 3A  ,since 58D = 3AH in AL
The result of AAD execution will give the hexadecimal number 3A in AL and 00
in AH. Where 3A is the hexadecimal Equivalent of 58 (decimal).

DAA : Decimal Adjust Accumulator
This instruction is used to convert the result of the addition of two packed BCD
numbers to a valid BCD number. The result has to be only in AL.
Eg.
AL = 53 CL = 29
ADD AL, CL ; AL <– (AL) + (CL)
                    ; AL 53 + 29
                    ; AL 7C
DAA ; AL 7C + 06 (as C>9)
        ; AL 82

DAS : Decimal Adjust after Subtraction
This instruction converts the result of the subtraction of two packed BCD numbers to
a valid BCD number. The subtraction has to be in AL only.
Eg.
AL = 75, BH = 46
SUB AL, BH ; AL     2F = (AL) – (BH)
                    ; AF = 1
DAS ; AL 29 (as F>9, F – 6 = 9)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s