Question: Add comments to the following MIPS code and describe in one sentence what it computes. Assume the $a0 is used for the input and initially

Add comments to the following MIPS code and describe in one sentence what it computes. Assume the $a0 is used for the input and initially contains n, a positive integer. Assume that $v0 is used for the output.

begin: add $t0, $zero, $zero

loop: beq $a0,$zero,finish

add $t0, $t0, $a0

sub $a0,$a0,1

j loop

finish: addi $t0,$t0,100

add $v0,$t0,$zero

b) Write a MIPS program that reads two positive integers, x and y, and outputs x to the y power (xy). Assume the $s0 and $s1 are used for the inputs and initially contain x and y respectively, and $s5 is used for the output.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!