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: 2
Joined: Mon Jul 31, 2017 7:30 pm
Reputation: 0

need help understanding the carry flag..

Post by malis2007 » Fri Aug 11, 2017 5:44 pm

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: 36
Joined: Mon May 08, 2017 4:08 am
Reputation: 8

Re: need help understanding the carry flag..

Post by gir489 » Tue Aug 15, 2017 2:09 pm

According to the x86 official documentation from Intel, 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: 2
Joined: Mon Jul 31, 2017 7:30 pm
Reputation: 0

Re: need help understanding the carry flag..

Post by malis2007 » Thu Aug 17, 2017 3:05 pm

gir489 wrote:
Tue Aug 15, 2017 2:09 pm
According to the x86 official documentation from Intel, 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

Post Reply

Who is online

Users browsing this forum: No registered users