Unsigned integers are commonly used for memory addresses where overflows are ignored. |
add
), add immediate (addi
), and subtract (sub
) cause exceptions on overflow.
addu
), add immediate unsigned (addiu
), and subtract unsigned (subu
) do not cause exceptions on overflow.
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 |