# Arithmetic and Logical Operations of 8086 Microprocessor

In this article, we are going to discuss in brief about the **arithmetic and logical instruction/ operations of 8086 microprocessor**.

Submitted by Uma Dasgupta, on March 22, 2019

## Logical Instructions

**a) AND: Logical AND**

Atleast one of the operant should be a register or a memory operant both the operant cannot be a memory location or immediate operant.

**b) OR: logical OR**

Both inputs are low in this case

**c) NOT: logical invert**

**d) XOR: logical Exclusive OR**

**e) TEST instruction: Logical compare instruction**

It will do bit by bit AND operation on the operands. Each bit of the result is then said to be 1 if the corresponding bit else the result bit is said to zero.

**f) SHL: Shift left logical**

It will shift the operant bit by bit to the left and insert the zero in the newly introduced least significant bits. Here operant is not an immediate data.

**g) SHR: Shift right logical**

**h) SAR: Shift Right Arithmetic**

Same as the logical shift but it inserts the most significant bit of the operand in the newly inserted position.

**i) ROR (Rotate Right without carry)**

**j) ROL (Rotate left without carry)**

**k) RCR ( Rotate right through carry)**

**l) RCL (Rotate left through carry)**

## Arithmetic Operations

**(1) ADD**

In this operation we perform sum of data in two different registers.

Memory to memory operation is not possible. Source and destination operant cannot be a memory location.

Also the content of segment register cannot be added.

**(2) ADC ( Add with carry)**

Same as add instruction, but adds the carry flag bit.

**(3) INC ( Increment)**

Increment the data by 1 and immediate data cannot be an operand here.

**(4) DEC ( decrement by 1)**

Decreases data by 1 and immediate data cannot be an operand.

**(5) SUB**

It will subtract source operand from destination and result is stored in destination.

Both operands may not be a memory operand and destination operand must not be an immediate data.

**(6) SBB (Subtract with borrow)**

Borrow flag/ Carry flag is also subtracted.

**(7) CMP (compare)**

For comparison it subtract source operand from the destination, but result is not stored anywhere.

**(8) ASS (ASCII adjust AL after subtraction)**

It converts the result of subtraction of two valid unpacked BCD digits to a single valid BCD no. and takes AL as implicit operand.

**(9) AAM (ASCII adjust after multiplication)**

AAM converts the result of multiplication of two valid BCD digits to a single valid BCD no. takes AC as implicit operand.

It unpacks the result by dividing AX by 10 placing the quotient into AH and remainder in AL.

**(10) AAD (ASCII adjust before division)**

It converts unpacked BCD digits in AH and AL register in a single binary number in AX register in preparation for a division operation.

Before executing AAD placed most significant BCD digit in the AH register and least significant digit in AL register. Then the two BCD digits are combined in a single binary number by setting.

**(11) DAA (Decimal adjust accumulator)**

Used to convert the result of the addition of 2 packed BCD no. to valid BCD no. if lower nibble AL > 9.

**(12) DAS (Decimal address after subtraction)**

It converts the result of subtraction of two packed number to a valid BCD no.

**Conclusion:**

In this article I have discussed briefly about almost **all arithmetic and logical instructions of 8086 microprocessor**. I hope they have covered all we need to know about the operations performed by 8086 microprocessor if you have any further queries shoot them in the comment section below. See you in my next article till then stay healthy and keep learning!

TOP Interview Coding Problems/Challenges

- Run-length encoding (find/print frequency of letters in a string)
- Sort an array of 0's, 1's and 2's in linear time complexity
- Checking Anagrams (check whether two string is anagrams or not)
- Relative sorting algorithm
- Finding subarray with given sum
- Find the level in a binary tree with given sum K
- Check whether a Binary Tree is BST (Binary Search Tree) or not
- 1[0]1 Pattern Count
- Capitalize first and last letter of each word in a line
- Print vertical sum of a binary tree
- Print Boundary Sum of a Binary Tree
- Reverse a single linked list
- Greedy Strategy to solve major algorithm problems
- Job sequencing problem
- Root to leaf Path Sum
- Exit Point in a Matrix
- Find length of loop in a linked list
- Toppers of Class
- Print All Nodes that don't have Sibling
- Transform to Sum Tree
- Shortest Source to Destination Path

Comments and Discussions

**Ad:**
Are you a blogger? Join our Blogging forum.