Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Problem 0. (4 points. Consider the following C function: long func1(long x, long y, long z) { long t1 = 100 - x; long t2
Problem 0. (4 points. Consider the following C function: long func1(long x, long y, long z) { long t1 = 100 - x; long t2 = 4*y + t1; long t3 = 2 * (z - 3); long t4 = t2 + t3; return t4; } Show that the following assembly code: funci: movl suba leaq leaq ret $100, %eax %rdi, %rax C%rax,%rsi,4), %rax -6(%rax,%rdx,2), %rax is a correct translation of this program, by (a) giving an expression for the value func() returns, and (b) filling in the table below, showing the contents of each register in terms of the parameters T, y, and z after each instruction is executed. The first row shows register contents before the first instruction. Remember that the sequence of assembly instructions may not correspond exactly to the C code, as the compiler may rearrange things to minimize the number of instructions and registers used. Fill in each spot in the table, even where it does not change. %rdi %rsi %rdx Wrax x z Problem 1. (4 points) Repeat the above process for the following C code and assembly: long func2(long x, long y, long z) { long ti = 10*x; long t2 = z + t1; long t3 = y 8; long t4 = t3 + t2; long t5 = 4 * t4; long rval = ti + t5; return rval; } func2: leaq (%rdi,%rdi, 4), %rax adda %rax, %rax adda %rax, %rdx leaq -8C%rdx,%rsi), %rdx leaq (%rax,%rdx, 4), %rax ret %rdi %rsi %rdx %rax X Z ID
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