There's only no overflow if you're interpret those values as unsigned numbers - if you interpret your 0x84
as signed, there's definitely overflow:
- 0x84 interpreted as a signed 8-bit value is -124
- 0x30 interpreted as a signed 8-bit value is 48
- -124 - 48 = -172
-172 is outside of the range of a signed 8-bit value (-128 to +127) and that's why the OF
flag gets set. You should check CF
which indicates unsigned overflow.
From the Intel 64 and IA-32 Architectures Software Developer’s Manual, Volume 2 for CMP:
The comparison is performed by subtracting the second operand from the first operand and then setting the status flags in the same manner as the SUB instruction.
and for SUB:
The SUB instruction performs integer subtraction. It evaluates the result for both signed and unsigned integer operands and sets the OF and CF flags to indicate an overflow in the signed or unsigned result, respectively. The SF flag indicates the sign of the signed result.