Consider the following C code segment int myglobal 0 main
Consider the following C code segment:
int my_global = 0;
main() {
int x = 10;
int y = 20;
int z = 0;
z = myFunc(x,y);
}
int myFunc(int x, int y)
{
return x – y + my_global;
}
Translate the above C code to MIPS assembly code using the following assumptions. Also show the contents of the stack and the heap during and after the function call.
The stack and the static data segments are empty to begin with.
The stack and the global pointers start at addresses 0x7FFF FFFC and 0x1000 8000, respectively.
All function inputs are passed using argument registers and returned using return registers.
The functions can only use the $s registers starting from the $s0.
Save my_global integer into the heap (i.e. data memory location pointed by the global pointer).
Consider the following C code segment: int my global. main int x 10 int y 20 int z 0; z my Func (x, y) int my Func (int x, int y) return x y tr my global Translate the above C code to MIPS assembly code using the following assumptions. Also show the contents of the stack and the heap during and after the function call. The stack and the static data segments are empty to begin with. The stack and the global pointers start at addresses 0x7FFF FFFC and 0x1000 8000, respectively All function inputs are passed using argument registers and returned using return registers The functions can only use the s registers starting from the $s0. Save my global integer into the heap (i.e. data memory location pointed by the global pointer).Solution
section .text global _start ;must be declared for using gcc global my_global _start: mov ax x ;All the same operator sub ax y ; to evaluate from left to right add ax my_global ; because they all have the same mov z ax ; precedence.