need help understanding the carry flag..

Memory scanning, code injection, debugger internals and other gamemodding related discussion
Post Reply
malis2007
What is cheating?
What is cheating?
Posts: 3
Joined: Mon Jul 31, 2017 7:30 pm
Reputation: 0

need help understanding the carry flag..

Post by malis2007 »

Hello there :)
i have a problem understanding the carry flag :/
i added these lines to the SUB instruction in the CE's step 2 TUT

Code: Select all

pushad
pushfd
mov eax,2
add eax,1
popfd
popad
after the add instruction, why is the carry flag being set? (CF=1)
Image
and why is it cleared (CF=0) when i replaced this code:

Code: Select all

mov eax,2
with either 7,A or even F the carry flag is cleared? (CF=0)
e.g.

Code: Select all

mov eax,F
Image

Thanks for reading, and your help inadvanced.. :)

User avatar
gir489
RCE Fanatics
RCE Fanatics
Posts: 801
Joined: Mon May 08, 2017 4:08 am
Reputation: 616

Re: need help understanding the carry flag..

Post by gir489 »

[Link], the CF is set if an arithmetic operation generates a carry of the most significant bit. It also indicates an overflow condition for unsigned integers.

You'll notice that the AF flag was set on your 2nd permutation of the code. That's the Adjust Flag. This means that the lower 4 bits were carried instead.

malis2007
What is cheating?
What is cheating?
Posts: 3
Joined: Mon Jul 31, 2017 7:30 pm
Reputation: 0

Re: need help understanding the carry flag..

Post by malis2007 »

gir489 wrote:
Tue Aug 15, 2017 2:09 pm
[Link], the CF is set if an arithmetic operation generates a carry of the most significant bit. It also indicates an overflow condition for unsigned integers.

You'll notice that the AF flag was set on your 2nd permutation of the code. That's the Adjust Flag. This means that the lower 4 bits were carried instead.
Thanks for your reply,

but how does it set the carry flag when we add 2 to 1?
0010
+0001
-----
0011

User avatar
gir489
RCE Fanatics
RCE Fanatics
Posts: 801
Joined: Mon May 08, 2017 4:08 am
Reputation: 616

Re: need help understanding the carry flag..

Post by gir489 »

0 was carried.

Post Reply

Who is online

Users browsing this forum: No registered users