Question: This exercise deals with recursive procedure calls. For the following problems, the table has an assembly code fragment that computes the factorial of a number.

This exercise deals with recursive procedure calls. For the following problems, the table has an assembly code fragment that computes the factorial of a number. However, the entries in the table have errors, and you will be asked to ix these errors. For number n, factorial of n = 1 x 2 x 3 x .. .. x n.a. FACT: sw sw addi $ra, 4($sp) $a0, 0($sp) $sp, $sp, -8 slti $t0, $a0, 1 $t0, $0. Ll $v0, $0, 1 $sp. $sp, 8b. FACT: addi $sp, $sp, 8. sw sw $ra, 4($sp) $a0, 0($sp) add $50, $0, $a0 slti $t0, $a0, 2 beq $t0, $0, L1

Show the contents of the stack after each function call, assuming that the input is 4.

a. FACT: sw sw addi $ra, 4($sp) $a0, 0($sp) $sp, $sp, -8 slti $t0, $a0, 1 $t0, $0. Ll $v0, $0, 1 $sp. $sp, 8 $ra L1: beq addi addi jr addi jal addi Tw Tw mul jr $a0, $a0, -1 FACT $sp, $sp, 8 $a0, 0($sp) $ra, 4($sp) $v0, $a0, $v0 $ra

Step by Step Solution

3.25 Rating (151 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

It appears that youre providing two snippets of assembly code labeled a and b that are related to calculating the factorial of a number using recursio... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Computer Organization Design Questions!