Ok So im trying to understand flags....

when i set $eax = 0x80000000 and set $ecx = 0x90000000

I want to compare and jump for flags
so

cmp EAX, ECX
j(o,s,z,c)

I do not understand how comparing these two numbers get a carry flag but not an overflow flag. I assume the compiler compiles them as signed numbers with EAX being the minimum number(-2147483648) and ECX being wrong? at -1879048192 would cmp be similar to sub when it does it operation for instance

-2147483648 - (-1879048192) or -2147483648 + 1879048192
OR
-2147483648 - 1879048192

Ok So im trying to understand flags....

when i set $eax = 0x80000000 and set $ecx = 0x90000000

I want to compare and jump for flags
so

cmp EAX, ECX
j(o,s,z,c)

I do not understand how comparing these two numbers get a carry flag but not an overflow flag. I assume the compiler compiles them as signed numbers with EAX being the minimum number(-2147483648) and ECX being wrong? at -1879048192 would cmp be similar to sub when it does it operation for instance

-2147483648 - (-1879048192) or -2147483648 + 1879048192
OR
-2147483648 - 1879048192

Hi! It has nothing to do with the compiler (we have an assembler here), but the processor itself. Basically these hex values can be considered to be positive integers (i.e. 0 .. 0FFFFFFFFh).
Because of the operands being treated as unsigned values (unless you implicitly or explicitly render them signed) CF is being used rather than OF which in this case doesn't play.
This generally means that your question is arose by false assumption :)

This link can help you out if you're stuck with conditional jumps (or other opcodes as well).

Hope this helps. Good luck!

This article has been dead for over six months. Start a new discussion instead.