Midterm2_Sol_toupload.pdf - Problem 1(This question has 2...

This preview shows 1 out of 4 pages.

Page 1 of 9 Problem 1: (This question has 2 parts, including a and b) In the following assembly code, assume that the C-level integer i is held in register x5, while x6 and x20 hold the C-level integers k and result , respectively, and x17 holds the base address of the array A. a) Give the value of result (register x20) at the end of this program for i = 2, k = 5, and array A being as follows: index 0 1 2 3 4 5 6 7 8 A 12 8 3 0 20 0 0 0 0 Main: slli x5, x5, 3 add x5, x5, x17 ld x20, 0 ( x5 ) add x10, x0, x20 add x11, x0, x6 jal x1, Proc1 sub x20, x10, x6 Proc 1: addi sp, sp, -24 sd x5, 16 ( sp ) sd x6, 8 ( sp ) sd x20, 0 ( sp ) add x5, x0, x10 add x6, x0, x11 add x20, x0, x0 L1: bge x0, x6, Exit add x20, x5, x20 addi x6, x6, -1 beq x0, x0, L1 Exit: addi x10, x20, 0 ld x20, 0 ( sp ) ld x6, 8 ( sp ) ld x5, 16 ( sp ) addi sp, sp, 24 jalr x0, 0(x1)
Image of page 1

Subscribe to view the full document.

Student ID # Student Name Page 2 of 9 SP Show your work here. Result = k*A[i] – k Result = 5 * 3 – 5 = 10 b) What is the content of the stack during, and after the procedure call? Write the name of the registers (Ex. X20) and Indicate the stack pointer. (The stack is empty at the beginning, so you should not write anything in the “before” stack)
Image of page 2
Student ID # Student Name Page 3 of 9 Problem 2: Consider the following instructions. What are the values of the control signals generated by the control unit for these instructions?
Image of page 3

Subscribe to view the full document.

Image of page 4
You've reached the end of this preview.
  • Fall '08
  • LANG
  • Clock signal, #, 25%, 30%, BGE

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern