Question: Hi I have this homework assignment, please help! Im new to C programming. HW4-1 (50 points) Consider the following assembly code nov1 $1, %edx #

Hi I have this homework assignment, please help! Im new to C programming.  Hi I have this homework assignment, please help! Im new to

HW4-1 (50 points) Consider the following assembly code nov1 $1, %edx # line #1 xor1 %eax, %eax # line #2 novzb1 %sil, %ecx # line #3 novq .L3: %rdx, %rsi # line #4 andq xorq testq jne ret %rdi, %rsi # line #6 %rsi, %rax # line #7 %rdx, %rdx # line #8 .L3 # line #9 # line #10 in which comments (beginning with #) are used to number the lines. The preceding code was generated on shannon by compiling C code that had the following overall form long loop(long z, int num) long accum = long loopvar; for (loopvar . loopvar loopvar accun- return accum; Your task is to fill in the missing parts of the C code to get a program equivalent to the generated assembly code. On the way, answer the questions below. Keep in mind that the return value of a function is returned in register %rax and the first six arguments to a function are passed in %rdi, %rsi, %rdx, %rex, %r8, and %r9 (or portions thereof) in that order. A. Which registers hold program values z and num? (2x4pts) B. In which assembly code line number is accun updated on ench iteration of the loop? (3pts) C. In which assembly code line number is loopvar updated on each iteration of the loop? (3pts) D. What are the initial values of accus and loopvar? (2x3pts.) E. What is the test condition for loopvar? (5pts.) F. How does loopvar get updated? (5pts.) G. How does accun get updated? (Spts.) H. Fll n all the missing parts of the C code. (l1pts. for doing correctly based on above answers)

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!