8085 Program to find the HCF of two numbers

8085 is a Microprocessor which was developed by Intel in 1970s. All the instructions in this microprocessor are encoded in a single byte. Some of the instructions are followed by one or two bytes of data, which can be a memory address, an immediate operand or a port number.

In this post, we will write a program in 8085 to find the HCF of two numbers.

Algorithm

Start
Read first number(A)
Read second number(B)
Compare A and B
If A - B = 0 go to 11
If A - B < 0 go to 9
A <- A - B
go to 4
Swap A and B
go to 4
Store A
Stop

Flow Chart

Program

       LXI H, 2100H
       MOV A, M
       INX H
       MOV B, M
LOOP:  CMP B
       JZ STORE
       JC EXG
       SUB B
       JMP LOOP
EXG:   MOV C, B
       MOV B, A
       MOV A, C
       JMP LOOP
STORE: INX H
       MOV M, A
       RST-5

Example

2100H: 06
2101H: 08
2102H: 02  ->  output

Check out our other 8085 programs

Let us know in the comments if you are having any questions regarding this microprocessor program.

And if you found this post helpful, then please help us by sharing this post with your friends. Thank You

Leave a Reply