Friday, 10 November 2017

How to find gcd of two numbers in 8085, 8085 GCD Program

Gcd of two numbers in 8085, 8085 GCD Program


AIM:
 To write a program to determine GCD of Two Numberss

ALGORITHM:
 1.Compare number 1(no1) with number 2(no2).If no1==no2,go to step 3.Else if no1<no2 ,then exchange no1 and no2.
 2.no1=no1-no2; go to step 1
 3.Display result as no1.


PROGRAM:

           LXI H,8000H
           MOV A,M
           INX H
           MOV B,M
 L1:     CMP B
           JZ OUT
           JC L2
           SUB B
           JMP L1
L2 :     MOV C,B
           MOV B,A
           MOV A,C
           JMP L1
OUT:  STA 8003H
           HLT

OBSERVATION:

RESULT:
Thus the given array of data was arranged in ascending order.

 
;