Arithmetic Instructions of 8086

There are 117 instructions in 8086 microprocessor, out of which few are arithmetic instructions of 8086 and others are

  • Branch instructions
  • Control instructions

Arithmetic instructions of 8086

ADD BL, CL

This instruction is for adding two numbers. Here two registers should be given as operands, the first one is the storage destination.

MOV CL, 05H
MOV BL, 04H
ADD BL, CL
Result of this code is 09H which is stored in the BL register.

In the above example, it was an 8 bit addition , the result of two 8 bit numbers can also be a 9-bit number. That 9th bit is carry, which is shown by the carry flag. Most of the flags get affected after an arithmetic operation. 

ADC BL, CL

ADC stands for add with carry. Using 8086, 16-bit additions can be performed in one cycle, to perform 32-bit addition ( in 2 cycles ) , this instruction is used.

First the lower 16- bits are added separately , then if it has any carry that would be stored in the carry flag. Next we have to add higher 16-bits, higher 16-bit addition is affected by the carry of lower flags.

So while adding higher 16-bits we use this instruction.

ADC BL, CL

BL ← BL + CL + CF

SUB BL, CL

This is similar to addition, target storage is BL. And if there is any borrow , then the carry flag would become 1.

SUB BL, CL

BL ← BL – CL

SBB BL, CL

SBB stands for subtract with borrow.

SUB BL, CL

BL ← BL – CL – CF

INC BL

This is increment instruction.

BL   BL + 1

INC BYTE PTR [ BX ]

Increment the byte pointed BX in the data segment.

DS:[BX] ← DS:[BX] + 1

DEC BL

This is a decrement instruction.

DEC BL

BL ← BL – 1

MUL operand

In multiplication , we give only one operand, second operand in an accumulator. 

AL : 8 bit accumulator

AX : 16 bit accumulator

DX.AX :  32 bit accumulator 

MUL BL ( BL is 8 bit register )

AH ← AL x BL

8 bit number multiplied by an 8 bit number can be a 16-bit number.

MUL CX ( DX is 16 bit register )

DX.AX ← CX x AX

16 bit number multiplied by a 16 bit number can be a 32-bit number.

IMUL operand

This is also a multiplication instruction , but this is for signed numbers. MUL was for unsigned numbers. 

DIV operand

This is division instruction, in this also we can give only operand which is divisor, divided work is done by the accumulator. 8086 doesn’t work with floating numbers. So the result of division is stored in the form of quotient and remainder. So we never divide dividend/ divisor when
Divisor > dividend, because the result would be 

5 / 7 = quotient = 0

Remainder = 5 ( divisor )

So we divide 

  • 16 bit number with 8 bit number
  • 32 bit number with 16 bit number

54 / 27 ; both are 8 bit numbers, so 54 should be saved as 0054.

DIV BL

AH.AL ← AX / BL

AH stored remainder, AL stores quotient

DIV BX

DX.AX ← DX.AX / BX

DX stores remainder, AX stores quotient 

IDIV operand

This is used for signed numbers , similar to IMUL.

CBW

This arithmetic instruction of 8086 instruction stands for convert byte to word ( word means 16 bit number ), this instruction is only for signed numbers. 

0101 is a +ve number ( MSB = 0 )

To make this nibble a byte, we simply put 4 zeroes

0000 0101 is an extended form.

1011 is a -ve number ( MSB = 1)

Its 2s complement is 5, it means it is -5

For this we have to put four ones at beginning 

1111 1011 , its 2s complement is 5, value didn’t change.

This is used for division , where we have to make extension of bytes into words.

CWD

This stands for convert word to d word ( d-word means 4 bytes ). This is similar to CBW. Even this instruction is also for signed numbers.

NEG BL

It simply negates the value in the register, which means saves the 2s complement of the number. 

NEG CL 

CL ← 2s complement 

CMP AL, BL

This compares the two numbers and gives the output.

CMP AL, BL

AL – BL

ConditionCFZF
AL > BL00
AL = Bl01
AL < BL10

Accoding to this table comparison is done.

DA A:   { decimal adjustment after addition }

This is a common and important arithmetic instructions of 8086, this instruction is also present in many other microcontrollers and microprocessors. Whenever an user gives numbers for operations numbers are given in decimal form ( not hexadecimal ), but the 8086 performs operations considering those numbers in hexadecimal form. Once the 8086 performs the operation it is sent to DA A for conversion to decimal form. 

arithmetic instructions of 8086

LN stands for lower nibble, HN stands for higher nibble.

CF stands for carry flag , AC stands for auxiliary flag.

Example 1:

Add 20 + 30 { user has given these numbers } ( decimal form )

8086 considers them hexadecimal numbers and performs hexadecimal addition. 

decimal adjustment after addition

LN ( 0 + 0 ) = 0 , LN is not > 9  and Auxiliary carry is not equal = 1

HN ( 2 + 3) = 5 , HN is not > 9  and Carry flag is not equal = 1

Both the conditions didn’t satisfy , so 50 is the final answer.

Example 2:

Add 25 + 25 { user has given these numbers } ( decimal form )

8086 considers them hexadecimal numbers and performs hexadecimal addition. 

decimal adjustment after addition

LN ( 5 + 5 ) = A , LN > 9  and Auxiliary carry is not equal = 1 , so add 06 to LN

HN ( 2 + 2) = 4 , HN is not > 9  and Carry flag is not equal = 1

One of the conditions is satisfied , so 4A is the not final answer.  Add 06 to 4A , so we get 50, which is the correct decimal form.

Example 3:

Add 50 + 50 { user has given these numbers } ( decimal form )

8086 considers them hexadecimal numbers and performs hexadecimal addition. 

decimal adjustment after addition

LN ( 0 + 0 ) = 0 , LN is not > 9  and Auxiliary carry is not equal = 1

HN ( 5 + 5) = A , HN > 9  and Carry flag is not equal = 1, so add 60 to HN

One of the conditions is satisfied , so A0 is not the final answer.  Add 60 to A0 , so we get 100, which is the correct decimal form.

Example 4:

Add 99 + 99 { user has given these numbers } ( decimal form )

8086 considers them hexadecimal numbers and performs hexadecimal addition. 

decimal adjustment after addition

LN ( 9 + 9 ) = 2 , LN is not > 9  and Auxiliary carry equal = 1, so add 06 to LN

HN ( 9 + 9) = 3 , HN > 9  and Carry flag is equal = 1, so add 60 to HN

Two of the conditions are satisfied , so 132 is not the final answer.  Add 60 to 132 and also 06 , so we get 196, which is the correct decimal form. 
Also this article can be referred for the topic.

Related topics:
Logical Instructions in 8086

Spread knowledge

Leave a Comment

Your email address will not be published. Required fields are marked *