{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

programb47 - Microprocessors Applications(UPTU Appendix B...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Microprocessors & Applications (UPTU) Appendix B ØØ Explanation : GCD of two numbers is performed by dividing the greater number by the smaller number till the remainder is zero. If it is zero, the divisor is the GCD if not the remainder and the divisor of the previous division are the new set of two numbers. The process is repeated by dividing greater of the two numbers by the smaller number till the remainder is zero and GCD is found. Example : First number = 90 Second number = 120 Iteration Operation Remainder 1 120 % 90 30 2 90 % 30 0 Hence, the GCD is 30. ØØ Algorithm : Step I : Initialise the data segment. Step II : Load AX and BX registers with the operands. Step III : Check if the two numbers are equal. If yes goto step X, else goto step IV. Step IV : Is number 1 > number 2 ? If yes goto step VI else goto step V. Step V : Exchange the contents of AX and BX register, such that AX contains the bigger number. Step VI : Initialize DX register with 00H.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}