- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# 8051 Program to Divide two 8 Bit numbers

Now we will see another arithmetic operation. The divide operation to divide two 8-bit numbers using this 8051 microcontroller. The register A and B will be used in this operation. No other registers can be used for division. The result of the division has two parts. The quotient part and the remainder part. Register A will hold Quotient, and register B will hold Remainder.

We are taking two number0EH and 03H at location 20H and 21H, After dividing the result will be stored at location 30H and 31H.

Address | Value |
---|---|

. . . | |

20H | 0EH |

21H | 03H |

. . . | |

30H | 00H |

31H | 00H |

. . . |

## Program

MOV R0, #20H;set source address 20H to R0 MOV R1, #30H;set destination address 30H to R1 MOV A, @R0;take the first operand from source to register A INC R0; Point to the next location MOV B, @R0; take the second operand from source to register B DIV AB ; Divide A by B MOV @R1, A; Store Quotient to 30H INC R1; Increase R1 to point to the next location MOV @R1, B; Store Remainder to 31H HALT: SJMP HALT ;Stop the program

8051 provides **DI VAB** instruction. By using this instruction, the division can be done. In some other microprocessors like 8085, there was no DIV instruction. In that microprocessor, we need to use repetitive Subtraction operations to get the result of the division.

When the denominator is00H, the overflow flag OV will be 1. otherwise it is 0 for the division.

## Output

Address | Value |
---|---|

. . . | |

20H | 0EH |

21H | 03H |

. . . | |

30H | 04H |

31H | 02H |

. . . |

- Related Questions & Answers
- Program to Divide two 8 Bit numbers in 8051 Microprocessor
- 8051 Program to Add two 8 Bit numbers
- 8051 Program to Subtract two 8 Bit numbers
- 8051 Program to Multiply two 8 Bit numbers
- 8085 Program to Divide two 8 Bit numbers
- Program to Subtract two 8 Bit numbers in 8051 Microprocessor
- Program to Multiply two 8 Bit numbers in 8051 Microprocessor
- Program to Divide two 8 Bit numbers in 8085 Microprocessor
- 8085 program to divide two 16 bit numbers
- 8085 Program to Add two 8 Bit numbers
- 8085 Program to Subtract two 8 Bit numbers
- 8085 program to multiply two 8 bit numbers
- 8085 program to swap two 8-bit numbers
- 8086 program to multiply two 8-bit numbers
- 8086 program to add two 8 bit BCD numbers