0

I a writing a simple MIPS code to add two hexadecimal values and store the results in a register. I am new to MIPS so I am having trouble finding the fix to an error message I have. Any help would be appreciated.

.text
    .globl main
main:   add $t2,$t0,$t1 # add contents of $t0 and $t1, and store result in $t2

    li $v0,10       # terminate execution
    syscall

the error message:

Error in C:\Users\smpan\OneDrive\Desktop\Computer\Computer Lab 2\Exercise4_3.asm line 4: Runtime exception at 0x00400000: arithmetic overflow

My goal for the program is to try and verify my hexadecimal addition is correct. I am adding 0x7FAA3278 and 0x6024CD12. The program should store the result 0xDFCEFF8A is the registered $t2. Line 14 is the line that contains main:

Ken White
  • 123,280
  • 14
  • 225
  • 444

1 Answers1

1

The result of that addition is too big to fit in a signed 32 bit value, and the CPU is telling you exactly that.

If you're expecting an unsigned result, or are happy with a negative result from adding two positive numbers, there's an 'add unsigned' instruction.

See here:

Difference between add and addu

user15187356
  • 807
  • 3
  • 3