Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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
Step: 1
Sure Lets break down the assembly code for each function and translate it back to C 1 Translating pp ...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started