flat assembler
Message board for the users of flat assembler.
Index
> Windows > big projects Goto page 1, 2 Next |
Author |
|
vid 26 Jul 2007, 15:57
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?
|
|||
26 Jul 2007, 15:57 |
|
realcr 26 Jul 2007, 18:28
Hi vid , thanks for your reply.
I use fasm to compile directly into executable. Can you recommend of a better way? realcr. |
|||
26 Jul 2007, 18:28 |
|
kohlrak 26 Jul 2007, 19:22
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?
|
|||
26 Jul 2007, 19:22 |
|
realcr 26 Jul 2007, 19:42
Just an example for the one of many ways I suffer
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. |
|||
26 Jul 2007, 19:42 |
|
kohlrak 26 Jul 2007, 21:42
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. |
|||
26 Jul 2007, 21:42 |
|
realcr 26 Jul 2007, 22:35
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. |
|||
26 Jul 2007, 22:35 |
|
kohlrak 27 Jul 2007, 02:12
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.
|
|||
27 Jul 2007, 02:12 |
|
realcr 27 Jul 2007, 10:21
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. |
|||
27 Jul 2007, 10:21 |
|
vid 27 Jul 2007, 10:41
Quote:
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) |
|||
27 Jul 2007, 10:41 |
|
realcr 27 Jul 2007, 14:33
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. |
|||
27 Jul 2007, 14:33 |
|
kohlrak 27 Jul 2007, 16:37
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. |
|||
27 Jul 2007, 16:37 |
|
realcr 27 Jul 2007, 17:30
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. |
|||
27 Jul 2007, 17:30 |
|
Furby 27 Jul 2007, 18:56
Are there any (FDP) FASM DESIGN PATTERNS like Singleton in OO thinking 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)
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 Don't steal my idea |
|||
27 Jul 2007, 18:56 |
|
realcr 28 Jul 2007, 09:35
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. |
|||
28 Jul 2007, 09:35 |
|
sleepsleep 28 Jul 2007, 12:33
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:
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. |
|||
28 Jul 2007, 12:33 |
|
rugxulo 31 Jul 2007, 02:29
Furby wrote:
Too late. http://rudy.mif.pg.gda.pl/~bogdro/inne/ bogdan wrote:
|
|||
31 Jul 2007, 02:29 |
|
Furby 01 Aug 2007, 14:56
Bogdan ty mendo ;D
Bogdro rox ;] |
|||
01 Aug 2007, 14:56 |
|
r22 02 Aug 2007, 13:07
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. |
|||
02 Aug 2007, 13:07 |
|
vid 02 Aug 2007, 13:29
idata and udata macros can do this without need for external utility
|
|||
02 Aug 2007, 13:29 |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.