Question: Consider a function P, which generates local values, named a0a8. It then calls function Q using these generated values as arguments. Gcc produces the following

Consider a function P, which generates local values, named a0–a8. It then calls function Q using these generated values as arguments. Gcc produces the following code for the first part of P:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 long P(long x) x in %rdi P: pushq pushq pushq pushq pushq

A. Identify which local values get stored in callee-saved registers.

B. Identify which local values get stored on the stack.

C. Explain why the program could not store all of the local values in calleesaved registers.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 long P(long x) x in %rdi P: pushq pushq pushq pushq pushq pushq subq movq leaq leaq leaq leaq leaq leaq movq leaq movq movl call %r15 %r14 %r13 %r12 %rbp %rbx $24, %rsp %rdi, %rbx 1 (%rdi), %r15 2(%rdi), %r14 3 (%rdi), %r13 4 (%rdi), %r12 5 (%rdi), %rbp 6 (%rdi), %rax %rax, (%rsp) 7(%rdi), %rdx %rdx, 8(%rsp) $0, %eax

Step by Step Solution

3.38 Rating (151 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

This example demonstrates the use of calleesaved registers as well as the stack for holding l... 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 Computer Systems A Programmers Perspective Questions!