Fake Branches

Real branches do only = and !=; fake branches do the others: <, <=, >, and >=

Here's some code using fake branches; you can paste it into MARS and assemble it:

.text

          blt   $10   $11   target  # branch on less than;                branches if $10 <  $11
          bgt   $12   $13   target  # branch on greater than;             branches if $12 >  $13
          bge   $14   $15   target  # branch on greater than or equal to; branches if $14 >= $15
          ble   $16   $17   target  # branch on less than or equal to;    branches if $16 <= $17
target:
      

THIS IS REALLY IMPORTANT: NEVER EVER USE $1 FOR ANYTHING!!!

Let's suppose that you were silly enough to do this anyway

One more thing: USE THE FAKES; do NOT expand them by hand

This page is not here because you'll ever have to do this yourself; it's here as a first example of how fakes are expanded; after all, this course is all about looking under the hood.