2. The 8086 provides many arithmetic operations: addition, subtraction,
negation, multiplication and comparing.
The arithmetic operation are performing in:
binary
packed BCD and
unpacked BCD.
3.
4. ASCII input
Conversion
….. Do work in binary
Conversion
ASCII output
Unpacked BCD format
Binary format
Binary format
Unpacked BCD format
5. BINARY ARITHMETIC
• BCD reference each of the digits of on unsigned decimal as the 4 bit binary equivalent
other binary arithmetic instructions, can operate on either bytes or words.
• All of them effective all of the condition flags . They may use any of the addressing
modes for one of the operands , but , except when the source operand is immediate , one
of the two operands must be a register
Binary addition and subtraction instructions.
Name Mnemonic and Format Description
Add ADD DST,SRC (DST) (SRC)+(DST)
Add with carry ADC DST,SRC (DST) (SRC)+(DST)+(CF)
Subtract SUB DST,SRC (DST) (DST)-(SRC)
Subtract with borrow SBB DST,SRC (DST) (DST)-(SRC)-(CF)
6. The arithmetic involving one word operands is called single – precision arithmetic,
involving two words operands is called double – precision arithmetic , and soon in
general , anything higher than single – precision is referred to as multiple precision.
Single – precision example Double – precision addition
MOV AX,X MOV AX,DP1
ADD AX,Y ADD AX,DP2
ADD AX,24 MOV DP SUM,AX
SUB AX,Z MOV AX,DP1+2
MOV W,AX ADC AX,DP2+2
MOV DP SUM+2,AX
7. Signed mixed mode arithmetic involving two different precision can be
performed by extending the sign of the shorter number until the numbers have the
same length. The CBW and CWD instructions are defined .
The CBW instructions extends the sign of the byte in AL to yield an equivalent
2’s complement 1-word result in AX. The CWD extends the sign of the word in AX
to DX , thus forming a double word in DX:AX
Name Mnemonic and format Description
Convert byte to
word
CBW Extend sign of AL to AH
Convert word to
double word
CWD Extend sign of AX to DX
8. • That INC and DEC leave the CF flag unchanged, all of the condition flags are
affected by these instructions.
• The INC, DEC and NEG instructions have only one operand.
Single operand binary arithmetic instructions and the compare instruction.
Name Mnemonic and Formats Descriptions
Increment INC OPR (OPR) (OPR)+1
Decrement DEC OPR (OPR) (OPR)-1
Negate NEG OPR (OPR) - (OPR)
Compare CMP OPR1,OPR2 (OPR 1)- (OPR 2)
9. The unsigned multiply instruction, MUL, treats the operands as unsigned
numbers and produces an unsigned product. To construct the IMUL and MUL
instructions
The IDIV nor DIV instruction leaves meaningful information in any of the
conditional flags and as with the multiply instructions.
IDIV BL
(AH)=24=3610 = remainder
(AL)=F3= - 1310 = quotient
DIV BL
(AH)=7C=12410 = remainder
(Al)=05=510 = quotient
10. PACKED BCD ARITHMETIC
• It packs two decimal digit into single byte.
• It is stored two digits to a byte , in 4 – bit groups referred to as nibbles.
• The ALU is capable of performing only binary addition and subtraction , but
adjusting the sum or difference the correct result in packed BCD format.
• The special addition and subtraction instructions are DAA and DAS are defined.
• DAA adds 6s where they are needed, DAS causes 6s to be subtracted.
11. PACKED BCD ADJUST INSTRUCTIONS
Name Mnemonic and Format Description
Decimal adjust for addition DAA (AL) Sum in AL adjusted
to packed BCD format
Decimal adjust for
subtraction
DAS (AL) Difference in AL
adjusted to packed BCD
format
13. UNPACKED BCD ARITHMETIC
• It is represents contains only one decimal digits per byte. The digit is stored in the
least significant 4 bits.
• The most significant 4 bits are not relevant to the value of the represented number.
• Unpacked BCD addition, subtraction and multiplication are accomplished in much
the same way as packed BCD addition and subtraction in that the binary operations
act on single byte.