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 


Auto-Assembly - How do I create a loop?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking
View previous topic :: View next topic  
Author Message
deama1234
Master Cheater
Reputation: 3

Joined: 20 Dec 2014
Posts: 328

PostPosted: Fri Jan 23, 2015 12:46 pm    Post subject: Auto-Assembly - How do I create a loop? Reply with quote

E.g. how do I make this code execute a certain amount of times?

Code:
push eax

dec eax // how do I make this execute like 4 times?

pop eax
Back to top
View user's profile Send private message
Krampus
Cheater
Reputation: 0

Joined: 22 Nov 2014
Posts: 41

PostPosted: Fri Jan 23, 2015 1:36 pm    Post subject: Re: Auto-Assembly - How do I create a loop? Reply with quote

deama1234 wrote:
E.g. how do I make this code execute a certain amount of times?

Code:
push eax

dec eax // how do I make this execute like 4 times?

pop eax


I'm not very good at ASM, but this is a rough idea of how it could be done.

Code:
push eax
push ecx
mov ecx,0

BeforeLoop:
cmp ecx,4
je AfterLoop
dec eax
inc ecx
jmp BeforeLoop

AfterLoop:
//Whatever you want done after the loop


This is probably a terrible way to do it, and I'm sure someone will post a better method.

_________________
There is no spoon.
Back to top
View user's profile Send private message
Geri
Moderator
Reputation: 111

Joined: 05 Feb 2010
Posts: 5636

PostPosted: Fri Jan 23, 2015 1:44 pm    Post subject: Reply with quote

Easiest way is to just execute it 4 times after each other.

Code:
push eax

dec eax
dec eax
dec eax
dec eax

pop eax


But if you want to do it "properly", you set up a value and use it as a counter. The counter would decrease/increase every time when that part is executed and if it will reach x amount, the loop will end.

Eg

Code:
counter_check:
cmp [counter],0  //if the counter is at 0, jump to exit
je exit

loop:
dec eax
dec [counter]     //decrease counter
jmp counter_check

exit:
mov [counter],4  //if you want to reset the counter


It's too much hassle. And if you want to reduce eax by 4, you can just use
sub eax,4

_________________
My trainers can be found here: http://www.szemelyesintegracio.hu/cheats

If you are interested in any of my crappy articles/tutorials about CE and game hacking, you can find them here:
http://www.szemelyesintegracio.hu/cheats/41-game-hacking-articles

Don't request cheats or updates.
Back to top
View user's profile Send private message
deama1234
Master Cheater
Reputation: 3

Joined: 20 Dec 2014
Posts: 328

PostPosted: Fri Jan 23, 2015 2:04 pm    Post subject: Reply with quote

Ah, thanks guys!

EDIT: I got another problem...
Code:
originalcode:
push eax

add [esi+00000224],09
mov eax,04

check:
cmp eax,0
    je exit
dec [esi+00000224]
dec eax
    jmp check

pop eax

As far as I can tell, that "dec [esi+00000224]" I'm trying to modify is inside a loop within the game, it's responsible for controlling the jump height.
What I'm trying to do is increase the jump height and I thought a loop would do it, it seems not...

So, uhh, how would I make "dec [esi+00000224]" decrement that "[esi+00000224]" value slower?

PS: The loop activates when I press and hold space, once I release it the loop seems to stop.
Back to top
View user's profile Send private message
Geri
Moderator
Reputation: 111

Joined: 05 Feb 2010
Posts: 5636

PostPosted: Fri Jan 23, 2015 5:43 pm    Post subject: Reply with quote

To answer that question, someone has to look at the whole code, not just a few lines. This is becoming too complicated.
But I recommend to look around and fiddle with conditional jumps to see what are they doing exactly.

_________________
My trainers can be found here: http://www.szemelyesintegracio.hu/cheats

If you are interested in any of my crappy articles/tutorials about CE and game hacking, you can find them here:
http://www.szemelyesintegracio.hu/cheats/41-game-hacking-articles

Don't request cheats or updates.
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