[prev] 11 [next]

Rendering C in MIPS: Conditional Statements (cont)

Could make switch by first converting to if

switch (Expr) {              tmp = Expr;
case Val1:                   if (tmp == Val1)
   Statements1 ; break;         { Statements1; }
case Val2:                   else if (tmp == Val2
case Val3:                            || tmp == Val3
case Val4:                            || tmp == Val4)
   Statements2 ; break;         { Statements2; }
case Val5:                   else if (tmp == Val5)
   Statements3 ; break;         { Statements3; }
default:                     else
   Statements4 ; break;         { Statements4; }
}