Homework #5

1. Convert the following conditional statements into MIPS assembly language.
For decision making, use only the slt, beq, and bne instructions.

Assume: a is in $t4,b is in $s0, c is in $s2. a,b and c are signed. (I've created some labels to make it easier - you may need more or different labels depending on your implementation)

if(a<b)
{
    a=c+a
}
after_if:
c=c+a

do
{
loop:
    b=b-a
} while(a!=b)
c=c+a

if(a<=b)
{
    b=b+b
}
after_if:
c=c+a

while(a>b)
{
    b=b-a
}
after_while:
c=c+a

for(a=b+b;a<c;a+=b)
{
    b=b+a
}
c=c+a

2. How would you solution to the above change if a and b were unsigned? (Re-Write the solution)

3. How could you "simplify" problem 1 if you used pseudo-ops? (Re-Write the solution)
   (Your new solution should at least be easier to read/understand)