Question
C AND ASSEMBLY (2) The following questions consider this sequence of assembly instructions that contains two functions f and g using the standard x86-64 calling
C AND ASSEMBLY (2)
The following questions consider this sequence of assembly instructions that contains two functions f and g using the standard x86-64 calling conventions:
f: cmpq $-12, %rsi jne .L2 movq %rsi, %rax movq %rdi, %rsi movq %rax, %rdi call f ret .L2: addq $1, %rdi movq %rsi, %rax imulq %rdi, %rax ret g: leaq -8(%rdi), %rsi leaq (%rdi,%rdi,2), %rdi call f ret
Fill in the blanks in the C code skeleton below using the most simplified expressions (and no spaces):
long f(long x, long y) { if (y ==) return f( , ); return ; }
cond:
farg1
farg2
ret
Suppose f is called with -2 in %rdi and 3 in %rsi. Give the values of the following registers just before f returns. It is recommended that you start from the beginning of f and trace the values of these registers as each instruction gets executed.
%rdi:
%rsi:
%rax:
Suppose f is called with 4 in %rdi and -12 in %rsi. Give the values of the following registers just before the original call to f returns. Again, it is recommended that you trace the register values through each instruction execution.
rdi:
rsi
rax
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started