Overflow


Overflow occurs when the result from an operation cannot be represented with the available hardware. When can overflow occur in addition and subtraction?
Unsigned integers are commonly used for memory addresses where overflows are ignored.
add addu (without overflow)
  .text
  li  $a0, 2147483647

   # largest signed word is
   #   0x7FFFFFFF = 231-1
   # = 2,147,483,647

  add $a0, $a0, 1
  li  $v0, 1
  syscall                 
  li  $v0, 10
  syscall
  .text
  li   $a0, 2147483647

   # largest signed word is
   #   0x7FFFFFFF = 231-1
   # = 2,147,483,647

  addu $a0, $a0, 1
  li   $v0, 1
  syscall                 
  li   $v0, 10
  syscall
Output Output

   


   





      Q: Why did the lion brake up with his girlfriend?    
      A: Cuz she was a CHEETAH!