Question

ARM assembly Code The Euclidean algorithm is a way to find the greatest common divisor of...

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=4·45+30.

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

Divide 30 by 15, and get the result 2 with remainder 0, so 30=2·15+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

1. If a<b, exchange a and b.

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

3. 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

Homework Answers

Answer #1

I have write assembly code for 8086 Assembly language program which is given below

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Using the Euclidean Algorithm, find the Greatest Common Divisor and Bezout Coefficients of the following pair...
Using the Euclidean Algorithm, find the Greatest Common Divisor and Bezout Coefficients of the following pair of integers: (2002, 2339)
Using the extended Euclidean algorithm, compute the greatest common divisor of 1819 and 3587.
Using the extended Euclidean algorithm, compute the greatest common divisor of 1819 and 3587.
(a) Show that the following algorithm computes the greatest common divisor g of the positive integers...
(a) Show that the following algorithm computes the greatest common divisor g of the positive integers a and b, together with a solution (u, v) in integers to the equation au + bv = gcd(a, b). 1. Set u = 1, g = a, x = 0, and y = b 2. If y = 0, set v = (g − au)/b and return the values (g, u, v) 3. Divide g by y with remainder, g = qy +...
Recursion in Java Write a recursive method that will find the greatest common divisor of two...
Recursion in Java Write a recursive method that will find the greatest common divisor of two numbers. Use %. Example of the math: Finding GCD for 14 and 48: 14 / 48 = 3 42 ----- 6 Remainder Remainder is not yet zero, so we will now divide 14 by 6 6 / 14 = 2 12 ----- 2 Remainder Remainder is not yet zero, so we will now divide 6 by 2 2 / 6 = 3 answer 6...
C CODE PLZ! All instructions are in sections of code #include <stdio.h> /* TODO: Define 3...
C CODE PLZ! All instructions are in sections of code #include <stdio.h> /* TODO: Define 3 functions input, gcd and lcm in such a way that the main function below compiles correctly and has the correct behavior. The input function prompts the user to enter a non-negative integer. If the user enters a negative integer, the function prints a "sorry" statement and prompts the user again. It keeps on prompting until the user enters a non-negative number. The input function...
. Let m be a positive integer, find the greatest common divisor of m and m+2
. Let m be a positive integer, find the greatest common divisor of m and m+2
Let m be a positive integer, find the greatest common divisor of m and m +...
Let m be a positive integer, find the greatest common divisor of m and m + 2. *Please go step by step*
Write a program called gcd that accepts two positive integers in the range of [32,256] as...
Write a program called gcd that accepts two positive integers in the range of [32,256] as parameters and prints the greatest common divisor (GCD) of the two numbers. The GCD of two integers a and b is the largest integer that is a factor of both a and b. One efficient way to compute the GCD of two numbers is to use Euclid’s algorithm, which states the following: GCD (a, b) _ GCD (b, a % b) GCD (a, 0)...
Using Windows 32 framework , write an assembly language program; Write a recursive procedure to find...
Using Windows 32 framework , write an assembly language program; Write a recursive procedure to find the greatest common divisor of two non negative numbers. You should use Euclidean algorithm and this is typically discussed in CSC 230. Your procedure: ❼ Needs to follow cdecl protocol. ❼ Needs to take two parameters. ❼ Should return -1, if the parameters are negative. ❼ Should return gcd, if the parameters are non negative. Your main procedure should do the followings. ❼ Read...
Assembly Language Programming create an .asm [assembly language program file, using Microsoft Visual Studio or equivalent...
Assembly Language Programming create an .asm [assembly language program file, using Microsoft Visual Studio or equivalent Windows32 integrated development environment (IDE)] program into one that inputs two positive integers, and outputs their greatest common divisor, by implementing the following pseudo-code: input num1 and num2 (assume num1 > 0 and num2 > 0) gcd := num1 remainder := num2 repeat numerator := gcd gcd := remainder remainder := numerator % gcd until (remainder == 0) output gcd The following 3 windows...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT