MIPS Overflow when adding two negative numbers

0

I have read in other questions that MIPS (32bit) Signed addition could result in overflow exception.

Now think that we have two numbers 0xB0000000 and 0xD0000000 in $s0 and $s1 and we want to add them using add $s2 $s1 $s0

should this raise an overflow?

I tested this with a simple program in MARS simulator and it didn't raise any overflow exception. the result was just 0x80000000 . But according to this question I think it should have raised an overflow exception.

So, Is the answer in that question wrong? Is it because I used MARS and not a real MIPS?

this is the simple program in mars:

.text
.globl main
main:
lw $s0, a
lw $s1, b
add $s2 $s1 $s0


add $a0 , $s2 , $zero
li $v0 , 1
syscall

.data
    a:  .word 0xB0000000
    b:  .word 0xD0000000

output: -2147483648

overflow
mips
mips32
asked on Stack Overflow Nov 15, 2019 by amir na

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0