Answered step by step
Verified Expert Solution
Link Copied!

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 ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Programming questions