20 likes | 98 Views
This function calculates the factorial of n in a loop for 16-bit numbers, with a maximal size of 131064 bytes. Features efficient implementation using MIPS assembly language instructions for addition and branching.
E N D
Answers to Quiz #1 1. mov $t0,$t1 ->add $t0,$t1,$zero bgt $t0,$t1,L1 -> slt $t2,$t1,$t0 bne $t2,$zero,L1 2. The functions computes the factorial of n in a loop. 3. The maximum size is 215-1 words (the maximal positive number of 16-bits) minus one word for the jump instruction. Thus the maximal size is 131064 bytes. 4. addi $t0,$t0,1 add $t0,$t0,$t1 add $t0,$t0,$t2
L1: bne $a0,$a1,End . . j L1 End: L1: beq $a0,$a1,L2 j End # jump is $a0!=$a1 L2: . . j L1 End: