I've been playing with assembly for a while and looking at some code. in which AL is first set to 0x84 then cmp AL, 0x30 is used. This instruction then triggers the Overflow flag.
From what I read CMP is supposed to subtract the second number from the first then set the flags, in that case it should be 0x84-0x30 the result is 0x54 and there is no overflow.
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:-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 checkCF
which indicates unsigned overflow.From the Intel 64 and IA-32 Architectures Software Developer’s Manual, Volume 2 for CMP:
and for SUB: