# MIPS Programming Homework - Updating Locations After Instructions

For my Assembly Language course, I have been asked to fill out a table for the Assembly code in Figure 1 MIPS Assembly Code as shown in Figure 2.

In this code, my instructor is trying to implement a recursive function call to complete a factorial of a number. Using the parameters in Figure 2, I have filled out the following so far.

Parameters and my progress

I know the initial stack pointer starts at location 100, then decreased by 12 per the first instruction in the function continue. The frame pointer is updated to 112 at location 96, the return address would be updated at location 92, and n would be updated to 2 at location 88. This would be repeated until n reaches 1.

I am confused about a few things though. My first question would be regarding the return address. In the locations where the return address would be updated (92,80, and 68), would the return address be 5000 each time or would it be updated automatically to something else? I am confused about how exactly the return address will be updated since it isn't explicitly updated like the frame pointer is during each iteration of the loop.

My second question is regarding the next instruction following the line of code:

jal fact # recursive call to fact(n-1)

After this is done the following instruction is listed

lw \$4, 0 (\$29) # restore n

Would this happen at location 60? And then for

mult \$2, \$4 # fact (n-1) * n

would this happen at location 56?

My final question is restoring each of the registers. In the lines of code:

lw \$4, 0 (\$29) # restore n
lw \$31, 4 (\$29) # restore return address
lw \$30, 8 (\$29) # restore frame pointer

where exactly would the values of n, return address, and frame pointer be restored to? Would they be loaded onto their original values of 88,92, and 96 respectively?

This is my first experience with Assembly language and I appologize if something I said doesn't make sense or show proper research. I was not provided any similar examples from my instructor so this is what I found after doing some research.