Lab3 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.5] What output do you expect when you run
p7-loop.asm? -
[3.6] Is the actual output what you expected?
-
[3.8] What output do you expect when you run
p7-loop.asm? -
[3.9] Is the actual output what you expected?
-
[3.11] If
SwapMaxWithLastneeded to return a value how would that be accomplished? -
[3.12] What changes would you need to make if
SwapMaxWithLastneeded more than 8 arguments? -
[3.13] What changes would you need to make if
SwapMaxWithLastcalled another procedure? -
[3.14] The code in
p7-loop.asmworks almost like a procedure. Describe the changes you would make to convert thep7-loop.asmcode into asortprocedure which is called and which in turn calls SwapMaxWithLast.
-
[4.2]
fibinfib.asmusessregisters to store bothnandfib(n ? 1). Couldtregisters be used? Which would you choose? -
[4.4] While calculating
fib(4), how many times isfibcalled? -
[4.5] In your
fibcode, you should have two internal calls tofib. Set a breakpoint at the line AFTER the first internal call tofib. Then, while calculatingfib(4), observe the state of the stack when the breakpoint is hit (e.g. when recursion using the firstjal fibis complete). Then, draw the state of your stack on the next page. Draw the stack as a rectangle, indicate each stack frame, and what register and value is present in each word. -
[4.5] What happens if
fibdoes not restore the return address before usingjr?
Draw your stack here: