Message board for the users of flat assembler.
> Main > Large project specifics...
AsmGuru62 28 Jan 2004, 19:45
Hi, everyone, first time here...
I have a couple of questions about FASM.
Basically, I need to know how good is FASM to build large projects?
1. By looking at the code in EXAMPLES folder in FASM - I can see that
I can include files with code as a simple INC files between the .code
section heading and the label 'start:' where entry point is. The question is
about labels - I may have a lot of labels in my separate files, like
'@@NEXT:' or '@@LOADCHAR:' or others. FASM would, most likely, consider
these labels to be duplicates. If so, how to avoid that - is there any 'local'
2. Is there any limits on identifiers? How many can there be?
Or this goes as far as memory allows.
3. Does the alignment of code/data is done using RB directive with '$'
parameter and some calculations? Say, I need to align the procedure at 32
byte frame. How to do that?
4. Is it possible to attach the RES file into FASM-compiled executable.
My point is - I do not want to use the resource building macros, but just
compile RC file separately and attach the RES into EXE.
5. How to deal with local variables? Say, I have a macro to reserve some
room in stack. How I can put my variables there and then use it by just a
name? In TASM, for example, I can use LOCAL section and once name is
defined there - any reference to it compiled as [EBP-xxxx]. Is there some
ability in FASM to do it in similar manner? Or I have to define, say, 'var1' as
[ebp-4], and 'var2' as [ebp-8] and so on for every procedure and then
just use 'var1' and 'var2' in the code?
I think, that is it for now.
And, of course, I appreciate any hints on building large projects in common.
|28 Jan 2004, 19:45||
Tomasz Grysztar 28 Jan 2004, 20:03
The question is
You can make a label local by putting the dot at the beginning (see sixth paragraph of section 1.2.3 in fasm's docs).
Is there any limits on identifiers? How many can there be?
Yes, only the amount of allocated memory limits you. With fasmw you can manually adjust the amount of memory that fasm might use, in the "Compiler" dialog; other versions just try to allocate as much of your memory as possible for that purpose (but DOS version is generally limited to 64 MB).
Does the alignment of code/data is done using RB directive with '$'
There is ALIGN directive in fasm, for both data and code alignment (see 2.2.3 in docs).
Is it possible to attach the RES file into FASM-compiled executable.
Yes, you can do it with "resource from" construction (see 2.4.2 in docs - I'm sorry there are no examples, I really should work a bit more on that part of docs...).
How to deal with local variables? Say, I have a macro to reserve some
Standard stdcall macros allow you to define local variables just this way:
proc MyProc, arg1,arg2 .local1 dd ? .local2 dd ? enter ; push ebp / mov ebp,esp / sub esp,8 mov eax,[.local1] ; mov eax,[ebp-8] mov eax,[.local2] ; mov eax,[ebp-4] mov eax,[arg1] ; mov eax,[ebp+8] mov eax,[arg2] ; mov eax,[ebx+4] return ; leave / ret 8
If you prefer to have your own proc macro, please look at the STDCALL.INC file in fasmw release to see how it is done.
Please also look at the Fresh project sources at http://fresh.flatassembler.net - this is a quite good example of large project developed with fasm.
|28 Jan 2004, 20:03||
AsmGuru62 28 Jan 2004, 22:12
That was fast... and useful.
Just one thing: I, probably, use some EBP/ESP manupulations instead of
LEAVE instruction. The compilers no longer use that, but instead the stack
frame is restored with a different (maybe, faster) code. I understand that
1 BYTE of LEAVE will expand to 3 or more, but that does not matter much,
because the project fucntions (only the frequent ones...) will be aligned anyway...
|28 Jan 2004, 22:12||
Tomasz Grysztar 28 Jan 2004, 23:45
On my processor LEAVE executes in the same amount of cycles as MOV ESP,EBP + POP EBP, and it's still simpler and smaller.
|28 Jan 2004, 23:45||
AsmGuru62 29 Jan 2004, 15:15
I tried this:
proc foo .wcls WNDCLASS ? enter mov [.wcls.style],CS_VREDRAW return
Did not compile...
|29 Jan 2004, 15:15||
decard 29 Jan 2004, 15:53
.wcls WNDCLASS ?
|29 Jan 2004, 15:53||
AsmGuru62 29 Jan 2004, 16:48
|29 Jan 2004, 16:48||
< Last Thread | Next Thread >
Copyright © 1999-2023, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.