flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
MHajduk
This works for me:
Code: format PE console 4.0 include 'win32a.inc' entry start section '.data' data readable array db "1a2b3c4d",0 fmt db "%c",0 section '.code' readable executable start: mov ecx, 0 mainLoop: cmp ecx, 8 jne print je okay print: lea eax, [ecx + array] push ecx cinvoke printf, fmt, [eax] pop ecx inc ecx jmp mainLoop okay: invoke ExitProcess, 0 section '.idata' data import readable writeable library kernel32, 'kernel32.dll', msvcrt, 'msvcrt.dll' import kernel32, ExitProcess, 'ExitProcess' import msvcrt, printf, 'printf' |
|||
![]() |
|
TmX
Ah I see. "lea eax [ecx + array]" means to load N-th element of the array into eax.
But why push ecx and pop ecx are also needed? |
|||
![]() |
|
MHajduk
TmX wrote: But why push ecx and pop ecx are also needed? |
|||
![]() |
|
Enko
In WinApi; esi, edi and ebx are the only register preserved. Other may and certenly will be modified by the function called in the api.
in your case, is better to use one of the preserved registers, so you don´t need to make the push pop. |
|||
![]() |
|
MHajduk
Yes, that's true. I just didn't want to change TmX's source too much (for clarity) and made only most important corrections.
![]() |
|||
![]() |
|
TmX
Enko wrote: In WinApi; esi, edi and ebx are the only register preserved. Other may and certenly will be modified by the function called in the api. Ah yes, I totally forget about this part. ![]() Thanks. |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.