Question: The remaining three problems in this exercise refer to the following function, given in both C and x86 assembly. For each x86 instruction, we also
The remaining three problems in this exercise refer to the following function, given in both C and x86 assembly. For each x86 instruction, we also show its length in the x86 variable-length instruction format and the interpretation (what the instruction does). Note that the x86 architecture has very few registers compared to MIPS, and as a result the x86 calling convention is to push all arguments onto the stack. The return value of an x86 function is passed back to the caller in the EAX register.
![b. void f(int a[], int n) [ int i; for(i=0;i!-n;i++) a[i]=0; } : 1B, push %ebp to stack : 2B, move %esp to](https://dsd5zvtm8ll6.cloudfront.net/images/question_images/1698/1/4/2/06965379775bce7e1698142068323.jpg)
Translate this function into MIPS assembly. Compare the size (how many bytes of instruction memory are needed) for this x86 code and for your MIPS code.
a. C Code int f(int a, int b, int c, int d) { if(a>b) return c: return d; } f: push %ebp mov mov %esp,%ebp 12(%ebp),%eax cmp %eax,8(%ebp) mov 16 (%ebp),%edx jle S pop %ebp. mov ret S: mov pop mov ret %edx, %eax 20 (%ebp),%edx %ebp %edx,%eax x86 Code : 1B, push %ebp to stack ; 2B, move %esp to %ebp : 3B, load 2nd arg into %eax ; 3B, compare %eax w/ 1st arg ; 3B, load 3rd arg into %edx : 2B, jump if cmp result is
Step by Step Solution
3.42 Rating (161 Votes )
There are 3 Steps involved in it
Based on the provided snippet heres the corresponding C code for t... View full answer
Get step-by-step solutions from verified subject matter experts
