please help...cannot get this code to work!
.const
para1 equ 0
para2 equ 0
.code
start:
print "Running.....",13,10
invoke poo para1,para2
print "Ended.",13,10
invoke ExitProcess,0
;procedure code
poo proc para1:DWORD,para2:DWORD
push ebp
mov ebp,esp
push esi
push edi
mov eax,[ebp+8]
mov ecx,[ebp+12]
dec eax
jnz poo
pop edi
pop esi
pop ebp
ret 8
poo endp
end start
maybe too much PUSH... :wink jump after...
Use a debugger and step through your code. Watch what is happening in your registers and on the stack. You will then certainly understand why it doesn't work.
You're also missing a coma between your proc name and the first parameter when you invoke the proc.
;procedure code
poo proc para1:DWORD,para2:DWORD
push ebp
mov ebp,esp
push esi
push edi
mov eax,[ebp+8]
mov ecx,[ebp+12]
loopie:
dec eax
jnz loopie
pop edi
pop esi
pop ebp
ret 8
poo endp
something like that maybe, but your code will deadlock, u sure u know where you're wanting to loop...
can't actually see the point of the proc though, can you explain a little more?
Each loop you mov 0 into eax then decrement eax (eax=-1), which makes it a never ending loop. From your procedure it looks like you want to setup the following loop:
loop00000:
dec eax
jnz loop00000
QuoteEach loop you mov 0 into eax
I would think he's moving the old value of EBP into EAX, which is a value of ESP prior to pushing all those registers!!! The stack eventually runs out of space and the program crashes.
You are correct Raymond.