Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


need help understanding the carry flag..

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking
View previous topic :: View next topic  
Author Message
malis2007
How do I cheat?
Reputation: 0

Joined: 31 Jul 2017
Posts: 1

PostPosted: Fri Aug 11, 2017 9:47 pm    Post subject: need help understanding the carry flag.. Reply with quote

Hello there Smile
i have a problem understanding the carry flag :/
i added these lines to the SUB instruction in the CE's step 2 TUT
Code:
pushad
pushfd
mov eax,2
add eax,1
popfd
popad


after the add instruction, why is the carry flag being set? (CF=1)
>>image in attachment <<

and why is it cleared (CF=0) when i replaced this code:
Code:
mov eax,2

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

>> image in attachment <<

Thanks for reading, and your help inadvanced.. Smile



f.png
 Description:
pushad
pushfd
mov eax,F
add eax,1
popfd
popad
 Filesize:  100.5 KB
 Viewed:  3651 Time(s)

f.png



c2.png
 Description:
pushad
pushfd
mov eax,2
add eax,1
popfd
popad
 Filesize:  100.2 KB
 Viewed:  3651 Time(s)

c2.png


Back to top
View user's profile Send private message
OldCheatEngineUser
Whateven rank
Reputation: 20

Joined: 01 Feb 2016
Posts: 1587

PostPosted: Fri Aug 11, 2017 10:12 pm    Post subject: Reply with quote

Quote:
Carry Flag

The rules for turning on the carry flag in binary/integer math are two:

The carry flag is set if the addition of two numbers causes a carry out of the most significant (leftmost) bits added. 1111 + 0001 = 0000
(carry flag is turned on)
The carry (borrow) flag is also set if the subtraction of two numbers requires a borrow into the most significant (leftmost) bits subtracted. 0000 - 0001 = 1111
(carry flag is turned on) Otherwise, the carry flag is turned off (zero).

0111 + 0001 = 1000 (carry flag is turned off [zero])
1000 - 0001 = 0111 (carry flag is turned off [zero])

_________________
About Me;
I Use CE Since Version 1.X, And Still Learning How To Use It Well!
Jul 26, 2020
STN wrote:
i am a sweetheart.
Back to top
View user's profile Send private message Visit poster's website
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Sat Aug 12, 2017 7:32 am    Post subject: Reply with quote

@OldCheatEngineUser the second image is 2 + 1, 00000010 + 00000001 = 00000011, at what point is that causing a carry out, or a borrow, from the most significant bit?

You can see the >> on the popfd so the add has been run but the flag restore has not.

Hello again @malis2007 Smile I'm sure it's something that'll seem simple once it's pointed out but I'm not seeing it either lol
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites