Question: In 80x86 Assembly language: In this assignment, we will get some experience with defining and calling functions with parameters. Please carry out the following steps:

In 80x86 Assembly language:

In this assignment, we will get some experience with defining and calling functions with parameters. Please carry out the following steps:

Make a copy of the CS238/VS2012_files/windows32 folder in your CS238 folder, and give HA8 as the name of this new copy.

Start VS2012, and open the project file CS238/HA8/windows32.sln.

In the Solutions Explorer window on the right, choose the file windows32/Source Files/example.asm and look at its text in the left window.

Change this program completely into one that contains a mainline and a gcd function that returns the greatest common divisor of two unsigned integers. The mainline should read two unsigned integers from the keyboard after displaying appropriate prompts. The mainline should then call the gcd function with those two values as arguments, obtain their greatest common-divisor from the function, and display it in an appropriate message. The gcd function should be based upon the following recursive C-like pseudo-code:

unsigned int gcd ( unsigned int a, unsigned int b ) { if ( a > b ) return gcd ( a - b, b ) ; if ( a < b ) return gcd ( a, b - a ) ; return a ; }

 

The parameters a and b should be passed to the above function by any caller on stack. The function returns its computed greatest common divisor value back to its caller in register eax. It should preserve the values of all other general-purpose registers.

The following 3 windows are an example interaction of the complete program (output in red, input in blue):

a: 24 b: 54 gcd: 6 

Submit your modified example.asm file on Blackboard for this assignment.

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!