GCD of two numbers using 8051 microcontroller.

This program finds the GCD of given two numbers and stores it in the register.


1) Store the num1 in R1 register and num2 in R2 register.
2) Compare whether num1>num2 and directly store result if num1=num2.
3) If num1>num2 assign numerator register to num1 and denominator register to num2 otherwise assign numerator register to num2 and denominator register to num1 otherwise.
4) Store the remainder in remainder register.
5) Repeat step 3 until the remainder is zero.
6) Store the value of gcd to the denominator.