A C++ program contains the following declaration of an external
assembly procedure:
extern "C" void doublebyref(int x, int& y);
The parameters x, y are assumed to be short integers that occupy two bytes
of memory each. Notice that x is passed by value, whereas y is passed
by reference. Standard C naming and calling conventions are assumed
to be in effect.
- (a)
Give the full proc / endp directives for the assembly procedure.
Do not include any explicit parameter declarations.
- (b)
Write assembly instructions that set up a stack frame within
the assembly procedure and then copy the value of the parameter x
to register ax. Previous contents of ax should be saved for future use.
- (c)
Write assembly instructions that double the value of x and store
the result in the location indicated by y. You may assume that the
stack frame has previously been set up and that x has been copied to
registers ax as described in part (b) of this problem.
- (d)
Write assembly instructions for the assembly procedure that
finalize the stack frame of part (b), perform any necessary
final tasks, and return control to the calling program.