Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In the following code snippet, where comments indicate line numbers: uint64_t x = uint64_t y 2; 5; uint64_t mul(uint64_t a, uint64_t b) { uint64_t e

image text in transcribedimage text in transcribed

In the following code snippet, where comments indicate line numbers: uint64_t x = uint64_t y 2; 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); // L7 } 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

Fundamentals Of Database Management Systems

Authors: Mark L. Gillenson

3rd Edition

978-1119907466

More Books

Students also viewed these Databases questions