How to tell if a binary sum of unsigneds gave overflow?

4

If I have a sum of two unsigned numbers (1 byte each) in an assembly without carry flag, how can I tell if it overflowed?

Edit: The architecture in question is Neander

Solution: I found a way to do this. First check the most significant bits (msb) of the numbers to be summed.

Se ambos forem 1, teremos overflow.
Senão, se apenas um deles for 1 e o msb do resultado for 0, teremos overflow
    
asked by anonymous 23.03.2017 / 19:32

3 answers

1

The commands "JO" (jump on overflow) or "JNO" (jump on not overflow) make this test possible and follow as appropriate.

    
23.03.2017 / 19:42
1

If the sum of two unsigned numbers results in a number less than the smallest number then an overflow has occurred. Example:

  1111  
+ 0001  
1 0000
    
23.03.2017 / 20:55
0

Solution: I found a way to do this. First check the most significant bits (msb) of the numbers to be summed.

If both are 1, we will have overflow.

Otherwise, if only one of them is 1 and the msb of the result is 0, we will have overflow

    
27.03.2017 / 19:43