Lab Exercise #8 -- SPARC Assembly Language A. Examine the SPARC assembly language program which is contained in the file named "~cse320/Labs/lab08.program.s" and answer the questions below. 1. Trace through the program, then complete the following to show the contents of the indicated registers after the program executes. Give a description (variable name or algebraic term) for the contents of each register, and give the value in the register as a decimal number and a hexadecimal number. If the program does not place a value into a given register, write "unknown" as your description (and leave the value fields blank). description decimal value hexadecimal value r16: ________________________ __________________ __________________ r17: ________________________ __________________ __________________ r18: ________________________ __________________ __________________ r19: ________________________ __________________ __________________ r20: ________________________ __________________ __________________ r21: ________________________ __________________ __________________ r22: ________________________ __________________ __________________ r23: ________________________ __________________ __________________ r24: ________________________ __________________ __________________ r25: ________________________ __________________ __________________ r26: ________________________ __________________ __________________ 2. What is the overall effect of the following pair of instructions? set A, %r27 ld [%r27], %r16 3. What is the overall effect of the following pair of instructions? set C, %r29 st %r21, [%r29] 4. What algebraic formula does this program compute? Give your answer in symbolic form (using "A" and "B"). 5. Copy the source code into your account, then add calls to "memory" and "iu_registers" to verify your answers. See the source code in the file named "Labs/lab08.sample.s" for examples of calls to those functions. After revising the program, translate, link and execute the program using UNIX commands similar to the following: gcc your_file.s ~cse320/lib/reglib.o a.out Check your answers against the values displayed by the "reglib" functions. 6. Based on the values displayed by the "reglib" functions, what are the addresses of each of the data items? Give your answers in hexadecimal. A: __________________ B: __________________ C: __________________ B. Design and implement the SPARC assembly language program specified below. 1. The program will compute the following function: 2 2 f(x,y,z) = (x+3) + 4xy - (2y) + z Assume that the values of "x", "y", and "z" will be supplied as data items in the ".data" section of the program. Use registers %r16 - %r29 for your intermediate results; do not use %r14, %r15, %r30 or %r31 (those four registers are used by the run-time system). Please note that you can re-use a particular register. Once you no longer need the value in that register, you can use it for a different purpose. Suggestion: copy the file containing your solution to Part A and edit the resulting file to complete this experiment. 2. Use your program to compute the following values. f(2,6,3) = ____________ f(3,7,5) = ____________ 3. Compare the expected results (computed by hand) against the actual results (displayed by the "reglib" functions) for both test cases. Revise your program, if necessary.