Translate the following C code into MIPS code.
int test (int n)
{
if (n < 2 ) return (10);
else
{
k = 20 + test (n-1);
k=k + n;
return (k);
}
}
Assume variable k is assigned to register $s1. Note: your code should be complete.
please dont show me the software output,
MIPS Code:
.file 1 .previous .text .align 2 .globl test .ent test .type test, @function test: .frame $sp,0,$31 move $2,$0 $L3: slt $3,$4,2 bne $3,$0,$L2 addiu $4,$4,-1 addiu $3,$4,21 b $L3 addu $2,$2,$3 $L2: j $31 addiu $2,$2,10 .end test .size test, .-test
Thank You!
Get Answers For Free
Most questions answered within 1 hours.