Arithmetic Immediate Instructions


The following table lists two add immediate instructions. No subtract immediate instructions are found in the MIPS instruction set. Both are with the I-type format:

Add Immediate Add Immediate without Overflow
 addi  rd, rs, imm
     # rd: destination register
     # rs: source register
 addiu  rd, rs, imm
     # imm: immediate value

Note that the formats of these instructions can not be found in the MIPS Assembly Language Programmer’s Guide. The instructor believes these instructions are redundant because the instructions add and addu can include immediate operands too.

add addi subiu
     .data
 X:  .byte  0xFF

     .text 
     lb   $a0, X
     add  $a0, $a0, 1
     li   $v0, 1
     syscall
     .data
 X:  .byte  0xFF

     .text 
     lb    $a0, X
     addi  $a0, $a0, 1
     li    $v0, 1
     syscall
     .data
 X:  .word  0x80000000

  # smallest signed word is
  #   0x80000000 = -231
  # = -2,147,483,648

     .text 
     lw     $t0, X
     subiu  $a0, $t0, 1
     li     $v0, 1
     syscall
Output Output Output