func (int, int, int): pushq %rbp movq %rsp, %rbp movl %edi, -20(%rbp) movl %esi, -24(%rbp) movl %edx, -28(%rbp) movl -20 ( %rbp), %edx movl -24 ( %rbp), %eax addl $edx, %eaх $11, %eax Fill in this c...


The portion of the generated assembly code implementing the C function int (int x, int y, int z) is as follows: Based on this assembly code, fill in the missing portions of the C code. Verify your answer using gcc compiler. Note: x in %edi, y in %esi, z in %edx.


func (int, int, int):<br>pushq<br>%rbp<br>movq<br>%rsp, %rbp<br>movl<br>%edi, -20(%rbp)<br>movl<br>%esi, -24(%rbp)<br>movl<br>%edx, -28(%rbp)<br>movl<br>-20 ( %rbp), %edx<br>movl<br>-24 ( %rbp), %eax<br>addl<br>$edx, %eaх<br>$11, %eax<br>Fill in this c code based on the assembly code:<br>addl<br>movl<br>Веax, -4 (8rbp)<br>movl<br>-4 ( %rbp), %eax<br>Int func(int x, int y, int z){<br>subl<br>$4, %eax<br>movl<br>веах, -8(8rbp)<br>}<br>int main(){<br>}<br>movl<br>-8 ( %rbp), %eax<br>popq<br>%rbp<br>ret<br>main:<br>pushq<br>%rbp<br>movq<br>%rsp, %rbp<br>subq<br>$16, %rsp<br>movl<br>$3, %edx<br>movl<br>$2, %esi<br>movl<br>$1, %edi<br>call<br>func(int, int, int)<br>movl<br>%eax, -4(%rbp)<br>movl<br>$0, %eax<br>leave<br>ret<br>

Extracted text: func (int, int, int): pushq %rbp movq %rsp, %rbp movl %edi, -20(%rbp) movl %esi, -24(%rbp) movl %edx, -28(%rbp) movl -20 ( %rbp), %edx movl -24 ( %rbp), %eax addl $edx, %eaх $11, %eax Fill in this c code based on the assembly code: addl movl Веax, -4 (8rbp) movl -4 ( %rbp), %eax Int func(int x, int y, int z){ subl $4, %eax movl веах, -8(8rbp) } int main(){ } movl -8 ( %rbp), %eax popq %rbp ret main: pushq %rbp movq %rsp, %rbp subq $16, %rsp movl $3, %edx movl $2, %esi movl $1, %edi call func(int, int, int) movl %eax, -4(%rbp) movl $0, %eax leave ret

Jun 06, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here