Ask your own question, for FREE!
Computer Science 9 Online
OpenStudy (s3a):

MIPS Assembly Word Problem (It seems easy despite it's wordiness but, I am new to this so I am confused)

OpenStudy (s3a):

"MIPS' native assembly code only has two branch instructions, beq and bne, and only one comparison instruction, slt. Using only these three instructions (along with the ori instruction to set b to 0 or 1), write (by hand) the MIPS assembly language equivalents for the following “C” high-level programming code snippets, assuming that a is stored in register #3, b is stored in register $4, c is stored in register $5, d is stored in register $6. Remember that in "C", if an expression is true, it evaluates to 1 and if false, it evaluates to 0. (a) b = ( b > c); (b) b = ( b < c) || (b > d); (c) b = (b != d) && (a != c) ; (d) b = (b <= c);" Could someone please show me how to do (a) so that I can understand how to attempt (b), (c) and (d)?

OpenStudy (anonymous):

So for (a): You can rewrite `b > c` into `c < b` (c is less than b). If this is the case, b should be non-zero, otherwise b should be zero. This is precisely what the `slt` instruction does. So you'll end up with this instruction: `slt b, c, b` (set b (the first one) if c < b (the second one)), or if you add the register numbers: `slt $4, $5, $4`.

OpenStudy (s3a):

Thank you! :)

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!