GCD of two numbers using 8051 microcontroller.

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 till the remainder in zero.
6) Store the value of gcd to denominator.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Advertisment ad adsense adlogger