0

Here is the assembly language code to test for signed overflow in addition:

addu $t0, $t1, $t2 
xor  $t3, $t1, $t2
slt  $t3, $t3, $zero
bne  $t3, $zero, No_overflow
xor  $t3, $t0, $t1
slt  $t3, $t3, $zero
bne  $t3, $zero, Overflow

what is the exact meaning of human language?

3
  • Is addu $to supposed to be addu $t0? "human language" - What do you mean by this? Do you not understand what xor means? Or bne? Commented Jul 26, 2017 at 4:30
  • The exact meaning of human language is a deep philosophical question and likely not what you intended to ask. Commented Jul 26, 2017 at 11:46
  • sorry,i did not use the proper description Commented Jul 26, 2017 at 14:04

1 Answer 1

3
  • Overflow only occurs when adding two numbers of the same sign (both positive, or both negative). Hence, the result of operand1 XOR operand2 should have the sign-bit cleared (since 0 XOR 0 and 1 XOR 1 both equal 0). That's what the first part is checking.
  • The second part is checking whether the sign of the result differs from the sign of the operands (only operand1 is used here since we know after the first part that both operands have the same sign). If the sign of the result is the same as the sign of the operands then no overflow occurred.
Sign up to request clarification or add additional context in comments.

1 Comment

Ahh, so this is signed overflow (vs unsigned overflow, the carry bit(vs overflow in multiplication)).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.