Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

3. Problem 3: In the following code snippet, where comments indicate line numbers: uint64_t x = 2; uint64_t y = 5; uint64_t mul(uint64_t a, uint64_t

image text in transcribedimage text in transcribed

3. Problem 3: In the following code snippet, where comments indicate line numbers: uint64_t x = 2; uint64_t y = 5; uint64_t mul(uint64_t a, uint64_t b) { uint64_t e = a * b; // LO return e; // L1 uint64_t comp(uint64_t n) { uint64_t e = 0; // L2 uint64_t f = 0; // L3 e = mul(x, n); // L4 f = mul(n, y); // L5 return e + f; // L6 } int main() { comp (2); // 17 3.1. Draw the stack, and show where the base pointer (%rbp) and the stack pointer %rsp) point right before L4 begins executing. 3.2. Draw the stack, and show where the base pointer (%rbp) and the stack pointer %rsp) point right before the call instruction that transfers control to the mul function is executed (that is, after arguments have been placed in the appropriate registers). What line of source code does the instruction pointer %rip) correspond to in this case? Note that some lines of C can expand into multiple instructions; your answer should specify the line of C code that led to the compiler producing the instruction at the address pointed to by %rip. 3.3. Draw the stack right after mul's prologue has finished executing. You can assume that mul was called from L4. 3.4. Draw the stack right after mul's epilogue has finished executing, but before the ret instruction has returned control to the caller. Also state what line of C source code the instruction pointer (%rip) corresponds to in this case. You should assume that mul was called from line L4. Similar to part (b), your answer should specify the line of C that led to the instruction pointed to by %rip being produced. 3. Problem 3: In the following code snippet, where comments indicate line numbers: uint64_t x = 2; uint64_t y = 5; uint64_t mul(uint64_t a, uint64_t b) { uint64_t e = a * b; // LO return e; // L1 uint64_t comp(uint64_t n) { uint64_t e = 0; // L2 uint64_t f = 0; // L3 e = mul(x, n); // L4 f = mul(n, y); // L5 return e + f; // L6 } int main() { comp (2); // 17 3.1. Draw the stack, and show where the base pointer (%rbp) and the stack pointer %rsp) point right before L4 begins executing. 3.2. Draw the stack, and show where the base pointer (%rbp) and the stack pointer %rsp) point right before the call instruction that transfers control to the mul function is executed (that is, after arguments have been placed in the appropriate registers). What line of source code does the instruction pointer %rip) correspond to in this case? Note that some lines of C can expand into multiple instructions; your answer should specify the line of C code that led to the compiler producing the instruction at the address pointed to by %rip. 3.3. Draw the stack right after mul's prologue has finished executing. You can assume that mul was called from L4. 3.4. Draw the stack right after mul's epilogue has finished executing, but before the ret instruction has returned control to the caller. Also state what line of C source code the instruction pointer (%rip) corresponds to in this case. You should assume that mul was called from line L4. Similar to part (b), your answer should specify the line of C that led to the instruction pointed to by %rip being produced

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Step: 3

blur-text-image

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

Online Systems For Physicians And Medical Professionals How To Use And Access Databases

Authors: Harley Bjelland

1st Edition

1878487442, 9781878487445

More Books

Students also viewed these Databases questions

Question

Explain basic guidelines for effective multicultural communication.

Answered: 1 week ago

Question

Identify communication barriers and describe ways to remove them.

Answered: 1 week ago

Question

Explain the communication process.

Answered: 1 week ago