Write a function gcd in assembly language, which takes two parameters, calculates and returns the gcd of those two numbers. You do not need to write the whole program. Just write the function part. The function should use the standard Linux registers for parameters and return values. Add additional comments to describe how you are doing the calculation.

Respuesta :

Answer:

Explanation:

The following is written in Java. It creates the function that takes in two int values to calculate the gcd. It includes step by step comments and prints the gcd value to the console.

       public static void calculateGCD(int x, int y) {

           //x and y are the numbers to find the GCF which is needed first

           x = 12;

           y = 8;

           int gcd = 1;

           //loop through from 1 to the smallest of both numbers

           for(int i = 1; i <= x && i <= y; i++)

           {

               //returns true if both conditions are satisfied

               if(x%i==0 && y%i==0)

                   //once we have both values as true we store i as the greatest common denominator

                   gcd = i;

           }

           //prints the gcd

           System.out.printf("GCD of " + x + " and " + y + " is: " + gcd);

       }

Ver imagen sandlee09
ACCESS MORE