flat assembler
Message board for the users of flat assembler.
Index
> Main > Functions in Asm |
Author |
|
roticv 27 Nov 2004, 12:30
char * is a pointer....
it should be proc function, x, y, z |
|||
27 Nov 2004, 12:30 |
|
bogdanontanu 27 Nov 2004, 13:39
in C
Code: My_Function(param_01,param_02, unsigned long * param_03); in TASM: Code: Call My_Function STDCALL, [param_01],[param_02], offset param_03 you do not need [] arround params if they are scalars: numerical constants, registers etc in MASM: Code: Invoke My_Function, param_01,param_02,addr param_03 in FASM: there are variouse macros that will allow you to do either: Code: Call My_Function,[param_01],[param_02],param_03 or: Code: STDCALL My_Function, [param_01],[param_02],param_03 There are evem more advanced macros in FASM, TASM,MASM that will allow you to do something like this: Code: Call My_Function, CSTRING("My first parameter"), Other_Function(other_param),offset param_03 However nice those things might look like... IMHO you should start with the basics like Code: push param_01 push param_02 push offset param_03 Call My_Function And improve in small steeps until you completly understand what you are doing and using... Also you should understand about ARGUMENTS and LOCAL variables inside functions ... and function PROTOTYPES There are also variavle numer of parameters lists like :VARARG for both functions and macros Usually the macro system of assemblers is much more powerfull than the one of C/C++ (a few magnitule levels better) |
|||
27 Nov 2004, 13:39 |
|
Nikolay Petrov 27 Nov 2004, 17:35
if you interest how translate "C" program of assembler use free bcc32 borland compiler with option "-S", when you compiled "C" or "C++" file - this option generate assempler file with detailed comment. In Windows - header "C" function you will "invoke" from crtdll.dll or msvcrt.dll
|
|||
27 Nov 2004, 17:35 |
|
gunblade 28 Nov 2004, 01:12
bogdanontanu, shouldnt that be:
Code: push offset param_03 push param_02 push param_01 call My_Function (as parameters require to be pushed in reverse order) gunblade |
|||
28 Nov 2004, 01:12 |
|
denial 29 Nov 2004, 18:33
thank your for all your replys
|
|||
29 Nov 2004, 18:33 |
|
LiuJunfeng 01 Dec 2004, 12:55
I think you are asking how to define a function in fasm, not how to call a function defined in C.
The code in a function starts like this: Code: MyFunc: push ebp mov ebp, esp ; use ebp as the frame pointer Then push callee save registers to be used and allocate memory on stack for local variables. Use [ebp+8],[ebp+12]...to access parameters passed to function. |
|||
01 Dec 2004, 12:55 |
|
vid 01 Dec 2004, 15:07
and ends with
Code:
mov esp,ebp
pop ebp
like, C's Code: int MyFunc(int a,int b) { int loc1,loc2 ;local variables return 0 } in asm Code: MyFunc: label b dword at ebp+8 label a dword at ebp+12 label loc1 dword at ebp-4 label loc2 dword at ebp-8 push ebp mov ebp,esp sub esp,8 ;8 is size of local variables ... code ... mov esp,ebp pop ebp retn this is low-level structure of procedure. However you can use FASM's standard "proc" macros to have less typing and have few more abilities (like if you don't use procedure anywhere, then it won't be defined, so you'll save some space in executable). |
|||
01 Dec 2004, 15:07 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.