View previous topic :: View next topic |
Author |
Message |
deama1234 Master Cheater
Reputation: 3
Joined: 20 Dec 2014 Posts: 328
|
Posted: Fri Jan 23, 2015 12:46 pm Post subject: Auto-Assembly - How do I create a loop? |
|
|
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 |
|
 |
Krampus Cheater
Reputation: 0
Joined: 22 Nov 2014 Posts: 41
|
Posted: Fri Jan 23, 2015 1:36 pm Post subject: Re: Auto-Assembly - How do I create a loop? |
|
|
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 |
|
 |
Geri Moderator
Reputation: 111
Joined: 05 Feb 2010 Posts: 5636
|
Posted: Fri Jan 23, 2015 1:44 pm Post subject: |
|
|
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
_________________
|
|
Back to top |
|
 |
deama1234 Master Cheater
Reputation: 3
Joined: 20 Dec 2014 Posts: 328
|
Posted: Fri Jan 23, 2015 2:04 pm Post subject: |
|
|
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 |
|
 |
Geri Moderator
Reputation: 111
Joined: 05 Feb 2010 Posts: 5636
|
Posted: Fri Jan 23, 2015 5:43 pm Post subject: |
|
|
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.
_________________
|
|
Back to top |
|
 |
|