I've writen the following MIPS assembly code to test for arithmetic overflow
.text
add $s0, $zero, 0x80000000
add $s1, $zero, 0xD0000000
add $t0, $s0, $s1
MARS is translates the code above into this:
lui $1, 0xffff8000
ori $1, $1, 0x00000000
add $16, $0, $1
lui $1, 0xffffd000
ori $1, $1, 0x00000000
add $17, $0, $1
add $8, $16, $17
I can't undertand why the add instructions got transformed into a lui/ori/add instrution since the constant added is 32bit and as far as I know $s0 is also 32bit. Also, where did 0xffff8000 come from? A constant in assembly is always assumed to be in two's complement, right? So why the conversion?
Thanks for the help.