Exercise 5A            Name       _____________________    Points ___/16

 
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                     invoke f, s, addr y
                                      push  offset y              mov    q, eAx
                                      call  f
                                      add   esp, 8
                                      mov   q, eAx
  

1. (3 pt)    int f4(int &a);

             x = f4( z );

 

 

 

 


 

2. (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) {
               return a+y;
            }
f  proc
   push  ebp
   mov   ebp, esp
   mov   ebx, [ebp+8]
   mov   eax, [ebp+12]
   add   eax, [ebx]
   pop   ebp
   ret
f  endp
f proc C, a:ptr dword, y:dword
       mov eBx, a
       mov eAx, [eBx]
       add eAx, y
       ret
f endp

                                      

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

 
 
 
 


 
 
 

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

 
 
 
 
 
 
 
 
 

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