Question: ARM assembly Code The Euclidean algorithm is a way to find the greatest common divisor of two positive integers, a and b. First let me

ARM assembly Code

The Euclidean algorithm is a way to find the greatest common divisor of two positive integers, a and b. First let me show the computations for a=210 and b=45.

Divide 210 by 45, and get the result 4 with remainder 30, so 210=445+30.

Divide 45 by 30, and get the result 1 with remainder 15, so 45=130+15.

Divide 30 by 15, and get the result 2 with remainder 0, so 30=215+0.

The greatest common divisor of 210 and 45 is 15.

Formal description of the Euclidean algorithm

Input Two positive integers, a and b.

Output The greatest common divisor, g, of a and b.

Internal computation

If a

Divide a by b and get the remainder, r. If r=0, report b as the GCD of a and b.

Replace a by b and replace b by r. Return to the previous step.

Your assignment is to write an assembler code (gcd.s) that asks the user two positive numbers and calculates their greatest common denominator.

For example, you program should produce the following outputs: Enter first positive integer: 6 Enter second positive integer: 8 The GCD is 2

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!