Arithmetic Instructions

warning: Creating default object from empty value in /var/www/vhosts/ on line 33.


AAD instruction (ASCII adjust for Division)
 If we divide a two-digit BCD number by a single digit BCD number, we put the dividend in AX and the divisor in a register or memory byte. After the BCD division AX will contain the BCD digit of the quotient. The AAD instruction provides a correction of an ASCII value prior to dividing. The ASCII data has to be converted to unpacked BCD format before doing the division.
 There are three steps in BCD division
1. Convert the dividend in AX from two BCD digits to their binary equivalent.


AAM instruction (ASCII Adjust for Multiply)
 The AAM instruction corrects the result of multiplying ASCII data in AX register.

 We must first convert the ASCII value into unpacked BCD value before performing multiplication (clear the 3 in the leftmost hex digit of each byte) so the AAM really corrects the BCD, not the ASCII data.

Decimal Arithmetic

 The BCD (binary Coded Decimal) number system uses four bits to code each decimal digit, from 0000 to 1001.  The combination of 1010 and 1111 are illegal in BCD.

The BCD representation of the Decimal digit 913 is 1001 0001 0011.(ie) each digit is converted into its equivalent four digit binary number.

Advantages of BCD format


MUL and DIV instructions
 The 8088 has instructions to support multiplication and division of binary and BCD numbers. Two basic types of multiplication division instructions for processing of unsigned and signed numbers are available.
MUL instruction
 MUL (multiply) instruction is used for unsigned multiplication. This instruction multiplies bytes or words. If two bytes are multiplied the product is a word (16 bit). If two words are multiplied the product is a double word (32 bit). MUL instruction assumes the MSB as data bit and not as sign bit.


INC instruction
 The INC instruction adds 1 to the contents of a register or memory location.
INC destination

The destination can be register or memory location.
The INC instruction affects AF, OF, PF, SF, and ZF.
 INC  BX  ; This instruction adds 1 to the content of BX


ADD instruction
       ADD instruction is used to add the contents of two registers, a register and a memory location, to add a number to the register or memory location. The ADD instruction adds the contents of source operand and the destination operand and stores the result in the destination operand.

Share |
Syndicate content