flat assembler
Message board for the users of flat assembler.
Index
> Main > masm to fasm for newb |
Author |
|
pelaillo 16 Mar 2004, 16:44
1. use proc macro
Code: proc MyProc,a,b dd wathever begin mov eax,[wathever] add eax,[a] return endp 2. use struct macro Code: mov [wc.cbSize],WNDCLASSEX ;or mov [wc.cbSize],sizeof.WNDCLASSEX 3. use virtual directive |
|||
16 Mar 2004, 16:44 |
|
chorus 16 Mar 2004, 17:10
Thanks! Seems simple enough
Just to make sure though, with the "dd" syntax for a local that does define it as a variable on the stack right? As opposed to defining a dword in the middle of my code? --Chorus |
|||
16 Mar 2004, 17:10 |
|
JohnFound 16 Mar 2004, 17:34
chorus wrote: Thanks! Seems simple enough Well, here are some details. There is standard macro library in FASMW package that provides macroses for these constructions: proc, struct, invoke, stdcall etc. Its syntax is a little diferent from the above examples: Code: proc ProcName, arg1, arg2, .... argN ; local variables, they will be created in the stack. .name1 dd ? .name2 dd ? .name3 rb 100 ; you can use every data definition instruction here. enter ; the body of the procedure. return Because of some reasons (more power and flexibility) the project Fresh and developers working on FASMs standard library prefere to use a little bit different proc definitions: Code: proc ProcName, arg1, arg2, .... argN ; local variables, they will be created in the stack. .name1 dd ? .name2 dd ? .name3 rb 100 ; you can use every data definition instruction here. begin ; the body of the procedure. return ; possibly another code return endp You can download this variant from Fresh package here: http://fresh.flatassembler.net Also I prefer to not use following construction: Code: mov [wc.cbSize],WNDCLASSEX It is absolutely equivalent to: Code: mov [wc.cbSize],sizeof.WNDCLASSEX but, "sizeof." variant is more readable and clear. About using structures with register indirect addressing: Code: mov [esi+WNDCLASSEX.cbSize], sizeof.WNDCLASSEX FASM is very flexible to do this kind of things, so after some experience, you will find the most comfortable for you way. Regards. |
|||
16 Mar 2004, 17:34 |
|
chorus 16 Mar 2004, 20:06
Thank you JohnFound. Details are good. I like details
Another question: How can I pass local variables to a proc through invoke? I try to do this: Code: proc InitClass,lpszClassName,lpfnWndProc,hIcon .wc WNDCLASSEX enter ... invoke RegisterClassEx,.wc return but the invoke to RegisterClassEx does not assemble. I have to "lea eax,[.wc]" and then "invoke RegisterClassEx,eax" (the same thing, I know, but it would be convenient to not have to do that). Thanks again --Chorus |
|||
16 Mar 2004, 20:06 |
|
JohnFound 16 Mar 2004, 20:14
chorus wrote: Another question: How can I pass local variables to a proc through invoke?.... This is not "the same thing". It is the "only way" to make it. MASM provide this behaviour hidden from the programmer. Of course it is possible to make the same behaviour for invoke macro for FASM, but I don't think this is good programming practice, for assembler. Regards. |
|||
16 Mar 2004, 20:14 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.