Exercise 6            Name       _________________    Points __/27

Give the corresponding Assembly code to do the following C++ function calls.
Example:    int f(int &a, int y);
            q = f(y, s);                    push  s
                                            push  offset y
                                            call  f
                                            add   esp, 8
                                            mov   q, eAx

1. (1 pt)    void f1(void);

             f1();
 
 
 
 

2. (2 pt)    void f2(int a);

             f2(5);
 
 
 

3. (3 pt)    int f3(int a);

             x = f3( z);
 
 

4. (3 pt)    int f3(int &a);

             x = f3( z );
 

5. (3 pt)    int f5(int a, int &b, int c);

             x = f5( 5, z, y);



Give the corresponding Assembly code to implement the following C++ functions.
Example:    int f( int &a, int y) {         f  proc  near
                return a+y;                    push  ebp
            }                                  mov   ebp, esp
                                               mov   ebx, [ebp+12]
                                               mov   eax, [ebp+8]
                                               add   eax, [ebx]
                                               pop   ebp
                                               ret 

                                            f  endp
6. (2 pt)    void f1(void) {
                 return;
             }
 
 
 
 
 
 
 
 
 

7. (3 pt)    void f2(int a) {
                cout << a;
             }
 
 
 
 
 
 
 
 

8. (3 pt)    int f3(int a) {
                return a+1;
             }
 
 
 
 
 
 
 

9. (3 pt)    int f3(int &a) {
                return a+1;
             }
 
 
 
 
 
 
 
 
 

10. (4 pt)    int f5(int a, int &b, int c);
                    return a+b+c;
              }