Question: 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;

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

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!