100% found this document useful (1 vote)
644 views2 pages

Write A Program of Division of Two 8 Bit Numbers

The document describes an algorithm and program for dividing two 8-bit numbers. It loads the numbers into registers, compares them to check for carry, subtracts them repeatedly, increments the quotient count, and stores the remainder and quotient in memory locations when finished.

Uploaded by

prashantvlsi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
644 views2 pages

Write A Program of Division of Two 8 Bit Numbers

The document describes an algorithm and program for dividing two 8-bit numbers. It loads the numbers into registers, compares them to check for carry, subtracts them repeatedly, increments the quotient count, and stores the remainder and quotient in memory locations when finished.

Uploaded by

prashantvlsi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

Write a program of division of two 8 bit numbers.

Algorithm
1. Start the program by loading HL register pair with address of memory location.
2. Move the data to a B register.
3. Get the second data and load into Accumulator.
4. Compare the two numbers to check for carry.
5. Subtract the two numbers.
6. Increment the value of carry .
7. Check whether repeated subtraction is over and store the value of product and carry
in memory location.
8. Terminate the program.

Program
LXI H, 5000

MOV B, M ;Get the dividend in B - reg.

MVI C, 00 ;Clear C - reg for quotient

INX H ;Increment HL pair of registers

MOV A, M ;Get the divisor in A - reg

NEXT: CMP B ;Compare A - reg with register B.

JC LOOP ;Jump on carry to LOOP

SUB B ;Subtract A - reg from B - reg.

INR C ;Increment content of register C.

JMP NEXT ;Jump to NEXT


LOOP: STA 5002 ;Store the remainder in Memory

MOV A, C ;Move Content of C - Reg to A - Reg

STA 5003 ;Store the quotient in memory

HLT ;Terminate the program.

Result
Input:

Data 1: FFH in memory location 5000

Data 2: FFH in memory location 5001

Output:

Data 1: 01H in memory location 5002 as Remainder

Data 2: FEH in memory location 5003 as Quotient

You might also like