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 


writing a conditional/ if statement in asm?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
catfood
Cheater
Reputation: 0

Joined: 22 Jun 2015
Posts: 34

PostPosted: Fri Sep 16, 2016 11:23 am    Post subject: writing a conditional/ if statement in asm? Reply with quote

Hey guys, so basically I'm asking this generally, because once I understand how it's written I can expand on it on my own. I'll write it out in laymans terms, I've tried dissecting some other scripts I've seen things like this done in, but it's usually done in huge scripts with allocations and all sorts of other things so I get a bit lost in which information is related to which.
so here's what I'd like to do, how might you script this?
thanks very much!

if
00BF3CC0 = 0
then
004C9FB7:
db 0f 83

otherwise
004C9FB7:
db 0f 86
Back to top
View user's profile Send private message
STN
I post too much
Reputation: 42

Joined: 09 Nov 2005
Posts: 2672

PostPosted: Fri Sep 16, 2016 11:34 am    Post subject: Reply with quote

cmp [00BF3CC0], 0
jne @F
mov word ptr [004C9FB7], 830f // Little Indians
jmp originalcode // jmp away anywhere to not execute the below code
@@:
mov word ptr [004C9FB7], 860f // Little Indians

_________________
Cheat Requests/Tables- Fearless Cheat Engine
https://fearlessrevolution.com
Back to top
View user's profile Send private message
catfood
Cheater
Reputation: 0

Joined: 22 Jun 2015
Posts: 34

PostPosted: Fri Sep 16, 2016 12:59 pm    Post subject: Reply with quote

okay so first let me say thanks for the quick reply! i saw it right away and have been playing with it since, wanted to get it working before i responded back.

so i added the originalcode, threw an [enable] and [disable] in the script, but for some reason am unable to check the box.
any idea why this might be? thanks!

again thanks for the help, hopefully once i understand this ill be able to expand on this new technique haha
Back to top
View user's profile Send private message
STN
I post too much
Reputation: 42

Joined: 09 Nov 2005
Posts: 2672

PostPosted: Fri Sep 16, 2016 5:36 pm    Post subject: Reply with quote

Post your full code. I simply responded with what you were asking, no idea if you are doing it correctly though or what you are doing at all
_________________
Cheat Requests/Tables- Fearless Cheat Engine
https://fearlessrevolution.com
Back to top
View user's profile Send private message
catfood
Cheater
Reputation: 0

Joined: 22 Jun 2015
Posts: 34

PostPosted: Fri Sep 16, 2016 9:12 pm    Post subject: Reply with quote

theres nothing else to the code, the entirety of what i want to acomplish is

if the db at 00BF3CC0 is db 00
then at address 004C9FB7, change the db to db 0f 83

otherwise
if the db at 00BF3CC0 is NOT db 00
then at address 004C9FB7, change the db to db 0f 86
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4289

PostPosted: Sat Sep 17, 2016 8:12 am    Post subject: Reply with quote

You need to create a thread if you want the game to run that code once. If you want it to run periodically, find a suitable spot for a code injection.
Code:
[ENABLE]
alloc(newmem,1024)
label(endIf)

createthread(newmem)

newmem:
  cmp [00BF3CC0],0
  jne @f
    mov word ptr [004C9FB7],830f
    jmp endIf
  @@:
    mov word ptr [004C9FB7],860f
  endIf:
  ret

[DISABLE]
dealloc(newmem)

Note that it is very bad practice to deallocate memory a thread is using. This particular thread won't spend even a millisecond executing this code, however, so no user should be able to deallocate the memory before the thread dies.

IMO Lua is a better alternative for automatically modifying values outside of a code injection.

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine 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