Out: Monday, 14 February
Latest Possible Submission Time: Wednesday, 16 February, 11:59pm
Turnin: Gradescope
These three questions are identical to questions 2, 3, and 4 from the midterm. IF you do this optional homework, your scores on those midterms questions will be set to the higher of the score you got on them on the midterm and the score on this optional homework.
sub: addi sp,sp,-48 sw s0,44(sp) addi s0,sp,48 sw a0,-36(s0) sw a1,-40(s0) sw zero,-24(s0) sw zero,-20(s0) jal x0,.L2 .L4: lw a5,-20(s0) slli a5,a5,2 lw a4,-36(s0) add a5,a4,a5 lw a5,0(a5) lw a4,-24(s0) add a5,a4,a5 sw a5,-24(s0) lw a5,-20(s0) addi a5,a5,1 sw a5,-20(s0) .L2: lw a4,-20(s0) lw a5,-40(s0) bge a4,a5,.L3 lw a4,-24(s0) addi a5,x0, 20480 addi a5,a5,-481 bge a5, a4, .L4 .L3: lw a5,-24(s0) addi a0, a5, 0 lw s0,44(sp) addi sp,sp,48 jalr x0, ra, 0
Question 2 - How many parameters does this C subourtine have?
Please include this question and your answer in the pdf file you submit.
(Note: The question numbers here are the same as the corresponding questions in the midterm. There is no question 1
in this homework.)
Question 3 - How many local variables does this C suboutine have?
Please include this question and your answer in the pdf file you submit.
Question 4 - Using the names P0, P1, P2, ... for the subroutine's parameters, if it has any, and L0, L1, L2, ... for its local variables, if it has any, write C code that corresponds to the assembler. (That is, write C code that might compile into the assembler shown above.)
Please include this question and your answer in the pdf file you submit. Please make sure to follow the directions in the question about variable names.