Division Programs in 8085 Microprocessor

In the article, there are few examples of division programs in8085 microprocessorin 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 location2202H 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

Leave a Comment

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