flat assembler
Message board for the users of flat assembler.
Index
> Main > How to combine PE sections in FASM? |
Author |
|
VitalOne 20 Jul 2004, 23:22
I'm not sure, but couldn't you split it up into different procedures, and have one code section, bss section, etc.. and just do something like call code_1, call code_2, etc...?
|
|||
20 Jul 2004, 23:22 |
|
comrade 21 Jul 2004, 00:43
I have had a similar concern and came up with this:
Code: ;################################ main.asm: macro includemods [mods] { reverse include mods } macro imod command,[mods] { forward command purge command } modules fix "module01.asm","module02.asm","module03.asm" section ".code" code readable executable imod code,modules ; include code from all modules section ".data" code readable writeable imod data,modules ; include data from all modules ;################################ module01.asm: macro code { ; code for module01 here } macro data { ; data for module01 here } ;################################ module02.asm: macro code { ; code for module02 here } macro data { ; data for module02 here } ;################################ module03.asm: macro code { ; code for module03 here } macro data { ; data for module03 here } Alternatively you can use COFF objects and a linker (the sane way). This is a macro hack. |
|||
21 Jul 2004, 00:43 |
|
zubi 01 May 2006, 08:17
For a more recent discussion on the issue, check this: http://board.flatassembler.net/topic.php?t=5176
|
|||
01 May 2006, 08:17 |
|
hopcode 28 Mar 2008, 00:12
Hallo to all, here is my partial solution, about
grouping dwords vars in only a data section. ... see the post following this, attached files long_myvar2.zip Hope this helps!! Last edited by hopcode on 29 Mar 2008, 00:46; edited 4 times in total |
|||
28 Mar 2008, 00:12 |
|
revolution 28 Mar 2008, 00:23
I think you misunderstand the "if used ..." operation. It does not detect a duplicate parameter name.
Also the line "argname equ argname#offs" is overloading the argname parameter, it is NOT reusing the same variable. The "LONG hClass" is in fact making two different variables. Check your output code to see what it generates. Another point, with allowing redeclaration of variables (if you manage to get it working properly) it is quite easy to make a mistake by reusing a name improperly and create a headache for you when you need to debug the problem. |
|||
28 Mar 2008, 00:23 |
|
hopcode 28 Mar 2008, 01:30
Yes,Yes,Yes
I must revisit it, because of the boundary (un)check of the data seg too; it can overwrite other sections causing eventually a GPF. Thanx a lot. .. I have it done for the creation of variables. Now the big problem is only with the boundary check. BTW, it is an exceptional case that someone is worryng about someones's headache but in the case that you have not all the problems you are speaking about, tell us the solution of this headache. We are all awaiting... Last edited by hopcode on 28 Mar 2008, 02:13; edited 2 times in total |
|||
28 Mar 2008, 01:30 |
|
revolution 28 Mar 2008, 01:49
hopcode wrote: Yes,Yes,Yes |
|||
28 Mar 2008, 01:49 |
|
hopcode 28 Mar 2008, 23:51
Here my definitive solution
for grouping dwords that, declared in OTHER modules, are stored in the MAIN (and the only) DATA SEG. Comments and suggestions appreciated. Code: format PE CONSOLE 4.0 entry start include '%fasminc%\win32a.inc' OFFS_INCR = 0 NUM_DWORDS = 0 macro LONG argname { virtual at DWORDS_DATA_START + OFFS_INCR argname: end virtual NUM_DWORDS = NUM_DWORDS + 1 OFFS_INCR = OFFS_INCR + 4 } section '.code' code readable executable include "module1.asm" include "module2.asm" start: LONG myVar1 LONG myVar2 LONG myVar3 mov dword [myVar1],1 mov dword [myVar2],2 mov dword [myVar3],3 cinvoke printf,szFormat,szMyVar,1,myVar1,[myVar1] cinvoke printf,szFormat,szMyVar,2,myVar2,[myVar2] cinvoke printf,szFormat,szMyVar,3,myVar3,[myVar3] cinvoke printf,szLine ;///////CALL PROC biberkopf_eins FROM module1.asm call biberkopf_eins cinvoke printf,szLine ;///////CALL PROC biberkopf_eins FROM module1.asm call biberkopf_zwei cinvoke printf,szLine cinvoke system,szPause ret section '.data' data readable writeable dummy dd 90909090h szPause db "pause",0 szFormat db "offset %s%ld=%ld, value=%ld ",13,10,0 szMyVar db "myVar",0 szMyGVar1 db "mod1_glob_var",0 szMyGVar2 db "mod2_glob_var",0 szLine db 09h,"----------------",13,10,0 ;....other data ;.... ;FROM THIS OFFSET DWORDS DATA ALIGN 4 DWORDS_DATA_START: dd NUM_DWORDS dup (0) section '.idata' import data readable writeable library msvcrt,'msvcrt.dll' import msvcrt,\ system,'system',\ printf,"printf" in the zip files module1.asm and module2.asm attached. see following post for update Hope this helps Last edited by hopcode on 30 Mar 2008, 01:12; edited 1 time in total |
|||
28 Mar 2008, 23:51 |
|
revolution 29 Mar 2008, 03:02
That looks much cleaner. Thanks for sharing.
|
|||
29 Mar 2008, 03:02 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.