Table of Contents
ToggleIn the article, there are few examples of division programs in 8085 microprocessor in assembly language programming (ALP). You need to learn the instruction set of 8085 in detail before programming.
Division Programs in 8085
Program for Division of Two 8-Bit Numbers in 8085
Write 8085 Assembly language program to divide a number stored at 2200H by the number stored in 2201H and store the quotient at location 2202H and remainder at 2203H.
LXI H, 2200H ; Load the HL pair register with the address 2200H of memory location
MOV B, M ; Copy the content of memory (2200H) into register B (Get the dividend).
INX H ; Increment register pair H-L.
MOV C, M ; Copy the contents of memory into accumulator (Get the divisor).
MVI D,00H ; Initialize counter to store Quotient.
MOV A, B ; Get dividend in accumulator.
LOOP: SUB C ; Subtract the content of accumulator with register C and store the result in accumulator.
INR D ; Increment the register D.
CMP C ; Compare the contents of accumulator and register C.
JNC LOOP ; Jump to Loop if carry flag is not set.
STA 2203H ; Store the remainder at memory location 2203.
MOV A, D ; Copy the content of register into accumulator.
STA 2202H ; Store the quotient at memory location 2202.
HLT ; Terminate the program execution.
Sample Example:
(2200H) = 0BH
(2201H) = 02H
Result = 0BH/02H = 05H Quotient and 01H remainder
(2202H) = 05H
(2203H) = 01H
Program for Division of 16-Bit Number by 8-Bit Number in 8085
Divide 16-bit number stored in memory locations 2200H and 2201H by the 8-bit number stored at memory location 2202H.
Store the quotient in memory locations 2300H and 2301H and remainder in memory locations 2302H and 2303H.
Program:
LHLD 2200H ; Get the dividend.
LDA 2202H ; Get the divisor.
MOV C, A
LXI D, 0000H ; Quotient = 0
BACK: MOV A, L
SUB C ; Subtract divisor.
MOV L, A ; Save partial result.
JNC SKIP ; if CY = 1 jump
DCR H ; Subtract borrow of previous subtraction.
SKIP: INX D ; Increment quotient.
MOV A, H
CPI 00 ; Check if dividend < divisor.
JNZ BACK ; if no repeat
MOV A, L
CMP C ; Compare the contents of accumulator and register C.
JNC BACK ; Jump to BACK if carry flag is not set.
SHLD 2202H ; Store the remainder.
XCHG ; Exchange contents of DE and HL pair
SHLD 2203H ; Store the quotient
HLT ; Terminate program execution
Sample Example:
(2200H) = 60H
(2201H) = 50H
(2202H) = 12H
Result = A060H/12H = 477H Quotient and 02H remainder.
(2300H) = 04H
(2301H) = 77H
(2302H= 02H
(2303H) 00H
Recent posts
Related posts:
- Terminology Used in Microprocessor and Microcontroller
- CISC and RISC Processor Architecture
- Von Neumann and Harvard Architecture
- Basics of Microprocessor and Microcontroller
- Introduction to Microprocessor 8085
- Architecture of 8085 Microprocessor
- Pin Diagram of 8085 Microprocessor and Pin Description
- Addressing Modes in 8085 Microprocessor
- Data Transfer Instructions in 8085 Microprocessor
- Arithmetic Instructions in 8085 Microprocessor
- Logical Instructions in 8085 Microprocessor
- Branching instructions in 8085 Microprocessor
- Machine Control Instructions in 8085 Microprocessor
- Timing Diagram of 8085 Instructions
- Stack and Subroutine in 8085 Microprocessor
- Interrupts in 8085 Microprocessor
- Assembler Directives of 8085 Microprocessor
- Simple Data Transfer Program in 8085 Microprocessor
- Microprocessor 8085 Addition and Subtraction Programs
- Programs on Logical Instructions in 8085 Microprocessor
- Multiplication Programs in 8085 Microprocessor
- Introduction to Assembly Language Programming
- 8085 Program to Find the Largest Number in an Array of Data
- 8085 Program to Count Negative Numbers | ALP to Count Negative Numbers
- 8085 Program to Find the Smallest Number in An Array of Data
- 8085 Program to Arrange an Array of Data in Ascending Order
- 8085 Program to Arrange an Array of Data in Descending Order
- 8085 Program to Find the Square of a Number from 0 to 9 Using a Table of Square