flat assembler
Message board for the users of flat assembler.

Index > Windows > big projects

Goto page 1, 2  Next
Author
Thread Post new topic Reply to topic
realcr



Joined: 02 Apr 2007
Posts: 39
realcr
Hi ppl.

I was recently trying to write fasm code as a large project.
It seems to be not that easy , as there are many decisions to make about how to divide code into files and such stuff.

Currently for every module I write , I make three files:
module_name.asm , module_name.dat , module_name.bss
and put each of them in the current section of the code.
[where the asm files contains functions , dat contains data , and bss contains bss data].

It doesn't seem like the best solution for me. Also I have to make a list of all the files I want to link to , and I didn't manage to split it between the modules. As , for example , only the input / output module uses the printf function , and I don't want that all the other modules will have to include that function]

I didn't manage to find any good revision control program for windows. I would like to know if there are any good ones for the windows platform.

I assume anyone who tried to actually write something big enough in fasm knows what I mean. Do you have any suggestions about the way to work?

realcr.
Post 26 Jul 2007, 15:26
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
First of all, do you use FASM to compile directly to executable, or do you compile every module to separate .obj file and then link them?
Post 26 Jul 2007, 15:57
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
realcr



Joined: 02 Apr 2007
Posts: 39
realcr
Hi vid , thanks for your reply.

I use fasm to compile directly into executable.
Can you recommend of a better way?

realcr.
Post 26 Jul 2007, 18:28
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
kohlrak



Joined: 21 Jul 2006
Posts: 1421
Location: Uncle Sam's Pad
kohlrak
Well, if you only use one program, it only gets included once anyway and it gets included globally. Or am i mis-understanding you? Could you give a little more on what you're trying to do?
Post 26 Jul 2007, 19:22
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger Reply with quote
realcr



Joined: 02 Apr 2007
Posts: 39
realcr
Just an example for the one of many ways I suffer Smile
for each module I have to include three files.
There must be a better way!

Code:
format PE console
entry start

include 'd:\programs\fasmw167\include\win32a.inc'     ; function macros
include 'fio.asm'                                        ; input / output

section '.data' data readable writeable

mess           db              "this is a test",13,10,0
num_show  db              "%d",13,10,0
out_filename  db              "out.txt",0
in_filename    db              "in.txt",0
testm           db              "test message",13,10,0
test_dbg    db              "test debug",13,10,0

; here I include the modules data
include              'module1.dat'
include              'module2.dat'


section '.bss' readable writeable

in_file   dd              ?
out_file   dd              ?


; here I include the modules bss
include                'module1.bss'
include              'module2.bss'


section '.code' code readable executable

start:


     ccall        in_init,in_filename              ; init input functions
        mov          [in_file],eax                    ; keep the context


    ccall        in_char,[in_file]
      ccall        dbg_print_num,eax                ; show what we got from the file
      ccall        in_char,[in_file]
      ccall        dbg_print_num,eax                ; show what we got from the file

  ccall        in_close,[in_file]


     cinvoke      ExitProcess,0                    ; exit and return zero

; here I include the modules assembly code
include               'module1.asm'
include              'module2.asm'


section '.idata' import data readable writable

  library kernel,'KERNEL32.DLL',msvcrt,'msvcrt.dll'

  import kernel,\
         ExitProcess,'ExitProcess'

  import msvcrt,\
       printf,'printf',\
        fprintf,'fprintf',\
      fopen,'fopen',\
  fclose,'fclose',\
        fgetc,'fgetc'

section '.reloc' fixups data readable discardable


    


p.s.
Do you know anything about using a revision control program with fasm under windows?

realcr.
Post 26 Jul 2007, 19:42
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
kohlrak



Joined: 21 Jul 2006
Posts: 1421
Location: Uncle Sam's Pad
kohlrak
What's the reloc for? i thought that was only for DLLs (correct me if i'm wrong)...

Yea, there is a better way. Include one file that includes those files.
Post 26 Jul 2007, 21:42
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger Reply with quote
realcr



Joined: 02 Apr 2007
Posts: 39
realcr
If I include only one file , it won't be in the right order.
I will have data sections and code sections in the middle of each other ,
because each of the modules have data , bss and code sections.
It seems wrong to me.

realcr.
Post 26 Jul 2007, 22:35
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
kohlrak



Joined: 21 Jul 2006
Posts: 1421
Location: Uncle Sam's Pad
kohlrak
put them in the right order in the other file, then when you include the one file it should put them in the right order.
Post 27 Jul 2007, 02:12
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger Reply with quote
realcr



Joined: 02 Apr 2007
Posts: 39
realcr
Hi kohlrak.

Thanks for your time and many replies , however I can't understand the idea you suggest. Do you mean writing everything in one file?

If I do so , I my files won't be modular anymore.
Maybe I should try to link object files like vid suggested , however I can't find a linker to do the job. Can I use the masm's linker for this purpose , and how do I tell the fasm assembler to produce .o windows file?

thanks,
realcr.
Post 27 Jul 2007, 10:21
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
Quote:

I use fasm to compile directly into executable.
Can you recommend of a better way?

It's good. FASM is designed for this way, and it isn't so well suited for other way (object files).

As for data (both initialized and BSS), you can keep them in same file as source, and use "idata" and "udata" macros for them. Here is implementation of those macros from FASMLIB:
Code:
;FASMLIB
;Basic data definition macros

macro idata arg
{
  __IData equ __IData,   ;add one ',' to __IData, initial "__IData" before ','s will be used to call macro
  macro __IDataBlock     ;begin macro (or overload old one) which holds data inside "idata" block
  arg
}

macro udata arg
{
  __UData equ __UData,
  macro __UDataBlock
  arg
}

;include all "idata"-defined blocks
macro IncludeIData
{
  macro __IData dummy,[n]  ;create macro which will be invoked, [n] makes sure macro's forward will
  \{                       ;be preprocessed for each ',' added to __IData
    \forward
       align 4
       __IDataBlock        ;use the macro with data
       purge __IDataBlock  ;and remove it so previous macro becomes avilable
  \}
  match I, __IData \{ I \} ;and now unroll __IData macro (just "__IData" wouldn't do, replaced equate isn't
                           ;preprocessed anymore and so it wouldn't beheave as macro usage)
  purge __IData            ;__Idata macro is not needed anymore
}


;include all "udata"-defined blocks
macro IncludeUData         ;... same as IncludeIData but it is whole in virtual to count size and define labels
{                          ;and then required space is reserved
  macro __UData dummy,[n]
  \{
    \common
       \local ..begin, ..size
       ..begin = $
       virtual at $
    \forward
       align 4
       __UDataBlock
       purge __UDataBlock
    \common
       ..size = $ - ..begin
       end virtual
       rb ..size
   \}
  match U, __UData
  \{
    U
  \}
  purge __UData
}

;use both macros at least once
idata{}
udata{}    


search around board for more info on these macros (or ask if you can't find anything)
Post 27 Jul 2007, 10:41
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
realcr



Joined: 02 Apr 2007
Posts: 39
realcr
Hi vid.

Thanks for the macros and fast reply.

I read the fasm macro documentation this morning just to understand what u wrote in there , As I don't tend to use things I don't understand how they work.

However I still don't understand many things about these macros and how to use them. Can you give any example of using these macros in a program?

I have seen many other posts of people asking about the data section , and how to make all the data you define in your files get there in the end.

It seems like fasm is not well suitable for object files [as you wrote before] , and have no well documented solution to do it using macros , as it was really hard to find any documentation of the macros you gave me.
I consider this to be a really serious problem for writing projects of a bigger size than 3 functions , and we must find a solution for that.

It can show up as a way to link files like I used to do in masm32 , or telling people how to use these macros. Macros that are probably great and working , but useless if they are not well explained somewhere.

realcr.
Post 27 Jul 2007, 14:33
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
kohlrak



Joined: 21 Jul 2006
Posts: 1421
Location: Uncle Sam's Pad
kohlrak
Quote:
If I do so , I my files won't be modular anymore.


Not what i ment... I ment this..

Code:
include file1.inc
include file2.inc    


Then call that, inc.inc...

Code:
include inc.inc    


Then it'll include file1.inc and file2.inc in the order you specified in inc.inc.
Post 27 Jul 2007, 16:37
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger Reply with quote
realcr



Joined: 02 Apr 2007
Posts: 39
realcr
Thanks for your reply kohlrak,

However that doesn't give any advantage over the way I did it. I still have to separate the code , data and bss into files and I don't think it is the way fasm programmers should work.
I'm trying to find a way to put stuff that have connection to each other together , in the same file , and not separate them.

Still trying to figure out how to use the macros from vid's message. It seems like they might be able to do the work.

realcr.
Post 27 Jul 2007, 17:30
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
Furby



Joined: 01 May 2007
Posts: 74
Location: Kraków, Poland
Furby
Are there any (FDP) FASM DESIGN PATTERNS like Singleton in OO thinking Wink Bit helpfull in LARGE PROJECTS , recently in my work I'm refactoring/refactorizing a program that has 260 000 lines of CODE in C# :O if it would be in ASM i would say simply "OH NO !" (Kurwa mac)

Smile So got any ideas ?

I think i will take on my next "home" project a FASM DOC program that will generate some documentation out of code Smile

Don't steal my idea Razz
Post 27 Jul 2007, 18:56
View user's profile Send private message Reply with quote
realcr



Joined: 02 Apr 2007
Posts: 39
realcr
I found this explanation about the udata and idata macros:
http://www.programmersheaven.com/download/50088/14/ZipView.aspx
Probably could useful to someone.

realcr.
Post 28 Jul 2007, 09:35
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
sleepsleep



Joined: 05 Oct 2006
Posts: 9002
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 334455
sleepsleep
we need a sort of framework, fasm framework. or just a set of dll that simplify the way to access / automate win32 or 64 api.

Quote:

I'm trying to find a way to put stuff that have connection to each other together , in the same file , and not separate them.

maybe we should have an IDE that able to split one file and make it appreared as several files.

eg.
;[FILE=mydata1.dat]
bla bla bla
keep on bla
;[FILE=mydata2.dat]
so long bla bla

once loaded in IDE, it would split it up, so i think it shoudl be IDE that makes programming adventure more easy. esp during handling big project.
Post 28 Jul 2007, 12:33
View user's profile Send private message Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo
Furby wrote:

I think i will take on my next "home" project a FASM DOC program that will generate some documentation out of code Smile

Don't steal my idea Razz


Too late.

http://rudy.mif.pg.gda.pl/~bogdro/inne/

bogdan wrote:

AsmDoc - HTML documentation generator

A Perl script which generates HTML documentation form the given source files, just like javadoc for Java: asmdoc.txt (2007-06-19).
The script is UTF-8 encoded and easy to translate into other languages. It generates valid HTML pages with no JavaScript, in any supported human language. Requires Perl 5.8 and a bunch of core modules. Run with no arguments to get help.
Post 31 Jul 2007, 02:29
View user's profile Send private message Visit poster's website Reply with quote
Furby



Joined: 01 May 2007
Posts: 74
Location: Kraków, Poland
Furby
Bogdan ty mendo ;D

Bogdro rox ;]
Post 01 Aug 2007, 14:56
View user's profile Send private message Reply with quote
r22



Joined: 27 Dec 2004
Posts: 805
r22
realcr, you may want to try not breaking up your files into different sections.

You can use a language like JAVA to code a source generator that will load up all your files find the .code .data sections and append them into one source file then compile that one source file.

Its an extra step but it would keep you from having to break up your files into sections.
Post 02 Aug 2007, 13:07
View user's profile Send private message AIM Address Yahoo Messenger Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
idata and udata macros can do this without need for external utility
Post 02 Aug 2007, 13:29
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page 1, 2  Next

< 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. Also on YouTube, Twitter.

Website powered by rwasa.