go to previous page   go to home page   hear noise   go to next page


        lw    $t0,val          # $t0 has the value
        andi  $t8,$t0,1        # one's place in $t8 is zero or one
        bnez $t8,odd           # if even
                               # {
        addu  $t2,$t2,$t0      #     add to even sum
        b     endif            # }
odd:                           # else
        addu  $t1,$t1,$t0      #     add to odd sum

Immediate Operand in Branch

If a branch instruction has a second operand, it can be an immediate operand or a register. The extended assembler will implement this using several basic instructions. For example, from the table:

bges,t,labelbranch if s>=t signed

Here are examples:

bge    $t1,$t2,spot     # if ( $t1 >= $t2 ) goto spot

bge    $t1,23,spot      # if ( $t1 >= 23  ) goto spot

bge    $t1,-98,spot     # if ( $t1 >= -98 ) goto spot

bge    12,$t1,oops      # WRONG: first op must be a register

bge    $t1,value,oops   # WRONG: second op can't be a symbolic address


Is the following instruction correct?

bge     $t1,-67,spot     # if ( $t1 >= -67 ) goto spot