Exercise 6            Name       _________________    Points __/20

Give the corresponding Assembly code to do the following.

1. (8 pt)    void f1(int X[], int n) {
                for(int i=0; i<n; i++)
                    X[i] = X[i]*2;

             }
 
 
 
 

2. (2 pt)    int A[] = {8, 3, 2, 7, 9};

             f1(A, 5);
 
 
 

3. (5 pt)    int gcd(a, b) {
               if (b == 0)
                  return a;
               else
                  return gcd(b, a mod b);
             }


4. (5 pt)    int f3(int X[], int n) {
                if( n < 0)
                   return 0;
                else
                   return f3( X, n-1) + X[n];
             }