New answers tagged

1

You can determine overflow for addition and subtraction of two signed bytes A and B as follows. First flip bit 7 of both A and B. This will not affect the result of (8 bit) addition or subtraction, nor of the sign flag, but it will affect the carry. Then for addition compute A+B. The overflow flag will be (carry == sign). For subtraction compute A-B. The ...


3

Overflow occurs on addition when two numbers with the same sign add up to a number with a different sign. It occurs on subtraction when two numbers with different signs produce a result with the same sign as the second number. So for addition of b and c, I guess something like: ; Compute result, store in h. ld a, b add c ld h, a ; Test for the same sign in ...


Top 50 recent answers are included