Question: Using a table, show the state of the x86-64 program stack at the point marked in the code shown below. Assume that %rsp = 0xffff0000
Using a table, show the state of the x86-64 program stack at the point marked in the code shown below.
Assume that %rsp = 0xffff0000 when execution enters the function main.
Make sure that you specify 1. changes to %rsp or %rbp and 2. what the value is or, if you dont have a specific value, you describe what it is for each line that affects the stack.
Be sure to indicate the address pointed to by rbp and the address pointed to by rsp at the point marked in the code.
Include information on the stack sheet for all lines of code in the program that affect the stack. Dont stop at the line indicated; do them all.
# There is no assumption that this is good code or that it even assembles or works.This is no
# more than an exercise to test your understanding of how the stack, %rbp and %rsp operate.
.section .rodata
.LC4:
.string "%i "
.globl main
.type main, @function
.globl printVal
.type printVal, @function
.text
main: # %rsp = 0xffff000 prior to any instructions
pushq %rbp # %rsp = 0xfffefff8, points to value of %rbp for stack
# frame above main()s
movq %rsp, %rbp # %rsp = 0xfffefff8, %rbp = 0xfffefff8, points to
# bottom of main()s stack frame
# c definition of function is: void printVal(int value, int *string1);
movq $5, %rdi # does not affect %rsp or %rbp
movq $.LC4, %rsi
movq $0, %rax
pushq %rax
pushq %rdi
pushq %rsi
pushq %r8
call printVal
popq %r8
popq %rsi
popq %rdi
popq %rax
leave
ret
.size main, .-main
printVal:
pushq %rbp
movq %rsp, %rbp
pushq %rdi
pushq %rsi
pushq %rbx
movq %rdi, %rsi #copy value to %rsi
movq $.LC4, %rdi
movq $0, %rax
#preserve registers before printf call
pushq %rax
pushq %rcx
pushq %rdx
pushq %rsi
callq printf
popq %rsi
popq %rdx #Show the state of the stack after execution of this instruction
popq %rcx
popq %rax
popq %rbx
popq %rsi
popq %rdi
leave
ret
.size printVal, .-printVal
Include in your answer (after execution of the indicated instruction): Address pointed to by rbp (that is, the contents of register rbp) = 0x Address pointed to by rsp (that is, the contents of register rsp) = 0x
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
