Question: MASM Assmebly Language x86 Processor: Greatest Common Divisor Program Hello Chegg experts, this is one of my programming assignments for MASM assembly language x86 Processor.

MASM Assmebly Language x86 Processor: Greatest Common Divisor Program

Hello Chegg experts, this is one of my programming assignments for MASM assembly language x86 Processor.

I really desperately need your help on this!! Also use Irvine32 library.

Here is the assignment:

(If you can't see the picture just read the assignment below the picture)

MASM Assmebly Language x86 Processor: Greatest Common Divisor Program Hello Chegg experts,

Greatest_Common_Divisor (Chapter 7, Pr 6)

The greatest common divisor of two integers is the largest integer that will evenly divide both integers. Refer to Euclid's algorithm. The algorithm involves integer division in a loop, described by the C++ code:

 int GCD(int x, int y) { x = abs(x); // absolute value y = abs(y); do { int n = x % y; x = y; y = n; } while y > 0; return x; } 

Implement this function in assembly language. Write a non-recursive procedure CalcGcd to calculate the GCD of two integers received from eax and ebx, and return EAX as GCD calculated for display. This is an example in action:

x % y = n 10 24 10 24 10 4 10 4 2 4 2 0 2 0 

The program will be run like this:

C:\Teaching\CSCI241\ch07\Debug>ch07_06 Enter a 32 bit number: 10 Enter a 32 bit number: 24 Greatest common divisor is: 2 C:\Teaching\CSCI241\ch07\Debug>ch07_06 Enter a 32 bit number: -100 Enter a 32 bit number: 48 Greatest common divisor is: 4 

Even when a negative entered. An alternative implementation (not required) is to use subtractions, as see from Using Euclid's algorithm.

I would really appreciate your help on this.

Thank you in advance..

Greatest_Common Divisor (Chapter 7, Pr 6) The greatest common divisor of two integers is the largest integer that will evenly divide both integers. Refer to Euclid's algorithm The algorithm involves integer division in a loop, described by the C++ code int GCD (int x, int y) absolute value xabs (x) y = abs (y): do while y>0: return x Implement this function in assembly language. Write a non-recursive procedure CalcGcd to calculate the GCD of two integers received from eax and ebx, and return EAX as GCD calculated for display. This is an example in action 10 10 24 10 24 10 The program will be run like this C:Teaching\CSCI241\chO7\Debng>ch07 06 Enter a 32 bit number: 10 Enter a 32 bit number: 24 Greatest common divisor is: 2 C:Teaching\CSCI2411cho7\Debng ch07 06 Enter a 32 bit nmnber: -100 Enter a 32 bit number: 48 Greatest common divisor is: 4 Even when a negative entered An alternative implementation (not required) is to use subtractions, as see from Using Euclid's aloorithm

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!