Question: 1. AC function declared as void pp (int p) { } is compiled to the MIPS code on the right. Write the C code

1. AC function declared as void pp (int "p) { } is

 

1. AC function declared as void pp (int "p) { } is compiled to the MIPS code on the right. Write the C code that performs the same operation as the MIPS code labeled 'pp' to the right in no more than two C statements. void pp (int *p) { } pp: pushq %rbp movq %rsp, %rbp movq %rdi, -8(%rbp) $0, -8(%rbp) je .L1 movq -8 (%rbp), %rax addq $4, %rax movq %rax, -8(%rbp) .L1: popq %rbp ret AC function prob declared as prob: pushq %rbp void prob(int *p1, int *p2){ } movq %rsp, %rbp is compiled to the x86 code on the right. Write the C function prob in ONE or TWO C statements that does the same thing as the x86 code labeled 'prob'. void prob(int *p1, int *p2) { movq %rdi, -8(%rbp) movq %rsi, -16 (%rbp) movq -16 (%rbp), %rax movl (%rax), %edx movq -8(%rbp), %rax movl (%rax), %eax addl %eax, %edx movq -16 (%rbp), %rax movl %edx, (%rax) } popq %rbp ret

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Sure Lets break down the assembly code for each function and translate it back to C 1 Translating pp ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!