flat assembler
Message board for the users of flat assembler.

Index > Main > Large project specifics...

Author
Thread Post new topic Reply to topic
AsmGuru62



Joined: 28 Jan 2004
Posts: 1408
Location: Toronto, Canada
AsmGuru62
Question 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'
directive?

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.

Cheers!
Post 28 Jan 2004, 19:45
View user's profile Send private message Send e-mail Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7714
Location: Kraków, Poland
Tomasz Grysztar
AsmGuru62 wrote:
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'
directive?

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).

AsmGuru62 wrote:
Is there any limits on identifiers? How many can there be?
Or this goes as far as memory allows.

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).

AsmGuru62 wrote:
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?

There is ALIGN directive in fasm, for both data and code alignment (see 2.2.3 in docs).

AsmGuru62 wrote:
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.

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...).

AsmGuru62 wrote:
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?

Standard stdcall macros allow you to define local variables just this way:
Code:
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.
Post 28 Jan 2004, 20:03
View user's profile Send private message Visit poster's website Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1408
Location: Toronto, Canada
AsmGuru62
Thanks!
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...
Post 28 Jan 2004, 22:12
View user's profile Send private message Send e-mail Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7714
Location: Kraków, Poland
Tomasz Grysztar
On my processor LEAVE executes in the same amount of cycles as MOV ESP,EBP + POP EBP, and it's still simpler and smaller.
Post 28 Jan 2004, 23:45
View user's profile Send private message Visit poster's website Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1408
Location: Toronto, Canada
AsmGuru62
I tried this:
Code:
proc foo
  .wcls WNDCLASS ?

  enter
  mov   [.wcls.style],CS_VREDRAW
  return
    

Did not compile...
Any workaround?
Post 29 Jan 2004, 15:15
View user's profile Send private message Send e-mail Reply with quote
decard



Joined: 11 Sep 2003
Posts: 1092
Location: Poland
decard
instead of
Code:
.wcls WNDCLASS ?    

try:
Code:
.wcls WNDCLASS    


regards
Post 29 Jan 2004, 15:53
View user's profile Send private message Visit poster's website Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1408
Location: Toronto, Canada
AsmGuru62
Awesome!
Post 29 Jan 2004, 16:48
View user's profile Send private message Send e-mail Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.