View previous topic :: View next topic |
Author |
Message |
Loset Cheater
Reputation: 0
Joined: 18 Apr 2015 Posts: 34
|
Posted: Fri Jun 26, 2015 3:52 am Post subject: Coding a loop around a call? //infinite loop ?! |
|
|
Code: | [enable]
alloc(myCode1, 1024)
label(myLoop)
005E3892:
jmp myCode1
nop
nop
nop
nop
nop
myCode1:
mov edx,8
mov ebx,8
push ecx
push edx
push eax
mov ecx,esi
myLoop:
call 005E28D0
inc eax
cmp eax,5
jne myLoop
jmp 005E389C
[disable]
dealloc(myCode1)
005E3892:
push ecx
push edx
push eax
mov ecx,esi
call 005E28D0 |
Code: | Edit: the problem is that eax changes to 0 after call so infinite loop...
how do I solve this?
|
this instruction call 005E28D0 I believe it is the shoot function.. is my loop correct? because I am getting crashes the only reason I can think of is that eax is already used so I cant use it as counter =/?
but maybe something else is wrong?
also if all registers are taken.. can I define somehow a new counter?
|
|
Back to top |
|
 |
Zanzer I post too much
Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Fri Jun 26, 2015 10:05 am Post subject: Re: Coding a loop around a call? //infinite loop ?! |
|
|
For simplicity, just define a new variable.
Code: | alloc(myvar,4)
inc dword ptr [myvar]
cmp dword ptr [myvar],5 |
However, you'll also need to save the values and re-push everything when making each call.
Code: | push ecx
push edx
push eax
mov ecx,esi |
|
|
Back to top |
|
 |
mgr.inz.Player I post too much
Reputation: 222
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Fri Jun 26, 2015 2:38 pm Post subject: |
|
|
Code: | push ebp
mov ebp,esp
mov ebx,8
mov edx,8
push esi
push ecx
push edx
push eax
//stack
//eax ebp-10
//edx ebp-0c
//ecx ebp-08
//esi ebp-04
//ebp ebp±00
loop:
push [ebp-08]
push [ebp-0c]
push [ebp-10]
mov ecx,[ebp-04]
call 005E28D0
inc [ebp-10]
cmp [ebp-10],5
jne short loop
mov esi,[ebp-04]
add esp,10
pop ebp
jmp 005E389C |
_________________
|
|
Back to top |
|
 |
Loset Cheater
Reputation: 0
Joined: 18 Apr 2015 Posts: 34
|
Posted: Fri Jun 26, 2015 3:22 pm Post subject: |
|
|
thanks guys you have been very helpful =] ! it took me a few hours but I now understand better the concept thanks.
|
|
Back to top |
|
 |
|