Exercise 5A            Name       _____________________    Points ___/16

Translate the following from C++ fragments to corresponding structured Assembler. Assume that i and j are defined as dwords. Use WriteDec and ReadDec for input and output.

 

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

             x = f4( z );

 

invoke     f4, addr z
2. (3 pt)    int f5(int a, int &b, int c);

             x = f5( 5, z, y);

invoke     f5, 5, addr z, y
3. (3 pt)    int f3(int a) {
                return a+1;
             }

 
f3      proc     C, a:dword
         mov     eAx, a
         inc        eAx
         ret
f3      endp
4. (3 pt)    int f3(int &a) {
                return a+1;
             }

 
f3      proc     C, a:ptr dword
         mov     eBx, a
         mov     eAx, [eBx]
         inc        eAx
         ret
f3      endp
5. (4 pt)    int f5(int a, int &b, int c);
                    return a+b+c;
              }

 
f5      proc     C, a:dword, b:ptr dword, c:dword
         mov     eAx, a
         mov     eBx, b
         add      eAx, [eBx]
         add      eAx, c
         ret
f5      endp