Lab2 questions
Name:
Section:
Name:
Section:
Read and perform the lab guide posted on the course website. Answer the questions in the lab guide as you get to them in the spaces below. The numbers below refer to steps in the lab guide.
-
[3.2] Where are
main
,loop
,done
,N
andSum
located (i.e. what address)? Hint: Assemble and use Settings > Show Labels Window in the Execute view. -
[3.4] How many instructions were actually executed? What is the final value of
Sum
? -
[3.6] How many instructions does your modified program execute when
N
is equal to 5? Can this number be improved? If so, how? Hint: If your modified program executes 5 or more additional instructions, you can do better. -
[3.7] Will your modified program work if
N
is less than 0? You do not need to make any additional modifications.
-
[4.3] What is the value of max and maxindex at the end of the program?
-
[4.4] Comment out
slli x10, x7, 2
and rerun the program. What happens? Why? -
[4.6] If you repeatedly apply your modified program to the subarrays of
A
from 0 to N−i where i is the number of times you've applied your program, what is the final state ofA
? -
[4.7] Like
p4.asm
this program doesn't work ifN
is equal to 0. It is brittle in other ways as well. For example, what happens if all of the elements are less than -1? Is there a more robust way to set the maximum value, instead of using the magic constant of -1? -
[5.2] What is the initial array displayed in the console window?
-
[5.4] What is the rotated array displayed in the console?