Reputation: 895
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?
Upvotes: 0
Views: 1016
Reputation: 58427
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.Upvotes: 3