Message board for the users of flat assembler.
> Main > Infinite loop
Ren 28 Jun 2007, 10:48
Why is this an infinite loop?
format PE CONSOLE
section '.data' data readable
msg db 'HELLO'
section '.code' code readable executable
section '.idata' import data readable writeable
|28 Jun 2007, 10:48||
kohlrak 28 Jun 2007, 11:36
try pushing and poping ecx before and after the printf accordingly.
|28 Jun 2007, 11:36||
revolution 28 Jun 2007, 12:22
Try using ebx, esi, ebp or edi instead of ecx. The 4 registers I mentioned there are preserved by the printf function whereas all the other registers (eax, ecx and edx) should be assumed to be clobbered.
|28 Jun 2007, 12:22||
kohlrak 28 Jun 2007, 12:42
I'd also like to note that your string isn't terminated (you seem to be using 10, but printf uses 0). That means it'll start printing the code of your Exe. Also, since each letter isn't null terminated, if you don't print out your code, the output would look a bit like this...
|28 Jun 2007, 12:42||
Ren 28 Jun 2007, 15:58
I did use ebx and that is OK.
But does it mean that I need to use ebx or push and pop ecx for all
the crtdll functions?
Are there other dll's who give problems with ebx or others that You
And Yes I got the HELLOHELLO.....
but no problem as I posted only because of the endless loop problem.
But never the less,
|28 Jun 2007, 15:58||
LocoDelAssembly 28 Jun 2007, 16:14
For every API function you call actually, it is the way stdcall and cdecl calling convention works. Only EBP, EBX, ESI and EDI are preserved. On stdcall ESP returns with the value prior to the first argument push and cdecl returns ESP with the same value it had before executing the CALL instruction.
|28 Jun 2007, 16:14||
Ren 29 Jun 2007, 04:28
Thanks, that's what I needed!
|29 Jun 2007, 04:28||
< Last Thread | Next Thread >
Copyright © 1999-2023, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.