flat assembler
Message board for the users of flat assembler.
Index
> Windows > calling msvcrt`s functions |
Author |
|
Vortex 03 Mar 2005, 08:11
Welcom to the forum.
You don't need to use the enter & leave statements: Code: format PE CONSOLE 4.0 entry start Include '%fasminc%\win32a.inc' section ".code" code readable writeable executable string db "Hello world :)",0 start: cinvoke printf,string invoke ExitProcess,0 section '.idata' import data readable writeable library kernel32,'kernel32.dll',\ msvcrt,'msvcrt.dll' import kernel32,\ ExitProcess,'ExitProcess' import msvcrt,\ printf,'printf' All this code equivalent to ( Ollydbg view ): Code: PUSH sample.00401000 CALL DWORD PTR DS:[<&msvcrt.printf>] ADD ESP,4 PUSH 0 CALL DWORD PTR DS:[<&kernel32.ExitProces> Notice that after C function calls, you need to balance the stack manually if you don't use the cinvoke macro. _________________ Code it... That's all... |
|||
03 Mar 2005, 08:11 |
|
rambo 03 Mar 2005, 08:34
thank you for fast reply. it works. but now i`ve got another problem. i won`t create new topic, so:
Code: fld dword [ebp-0x2c] how to assume ebp register to a stack segment, beacause that instruction is not decoded as i want..? and why fasm includes "wait" instruction after "fcomx", "fstsw"..? i know, how exactly my code should look, so how can i disable this "advantage".. |
|||
03 Mar 2005, 08:34 |
|
MCD 03 Mar 2005, 09:35
There is no assume directive in Fasm (for good reasons), you should rather use the virtual directive. See Flat Assembler Programmer's manual for details. Here's an example which will assemble to the same code as you wanted it:
Code: virtual at ebp-0x2C some_variable_name dd some_fp_value end virtual ;... maybe some code in between fld some_variable_name You can use the "fn" FPU-instructions, e.g. "fnstsw" instead of "fstsw" which could mean "Floating point No wait ...". If this is to unconventional for you, you can use equates to change the opcodes for those FPU instructions: Code:
fstsw equ fnstsw
finit equ fninit
fclex equ fnclex
;...
|
|||
03 Mar 2005, 09:35 |
|
rambo 03 Mar 2005, 13:22
mcd :: thank you.
|
|||
03 Mar 2005, 13:22 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.