flat assembler
Message board for the users of flat assembler.
Index
> Compiler Internals > section directive in binary format ? |
Author |
|
revolution 21 Mar 2008, 11:56
How are you going to encode the section format? Binary has no format so what is the assembler supposed to write to the output file when it sees "section ..."?
|
|||
21 Mar 2008, 11:56 |
|
pini 21 Mar 2008, 12:00
Well, I was thinking that the content of a given section could be regrouped before outputting to the file.
For instance: Code: section "text" mov eax,0 section "data" dd 0xAA section "text" mov ebx,1 would regroup the two instructions together and then output the data dword (with some mechanism to specify the order). No information about the section is outputted, they only serve as regroupers |
|||
21 Mar 2008, 12:00 |
|
revolution 21 Mar 2008, 12:11
The core of fasm doesn't work that way. But you can use macros to do section grouping. Search for macros on this board with names like udata, gdata, iglobals, uglobals and similar. Various implementations have been posted.
|
|||
21 Mar 2008, 12:11 |
|
pini 21 Mar 2008, 12:14
Thanks a lot !
I only needed a way to regroup things in the file, whether it's done with the section directive or some macros doesn't care for me. |
|||
21 Mar 2008, 12:14 |
|
revolution 21 Mar 2008, 12:18
Here is my little "globals" macros that probably does something close to what you need.
Code: ;file name: globals.inc v0.0 ; ;sets up five macros to define global data: ; ;.idata - declaration of initialised global data ;.udata - declaration of uninitialised global data ;.sdata - declaration of initialised global string data ;.bcode - declaration of one-time start up executed code ;.ecode - declaration of one-time shut down executed code ; ;and sets up another 5 macros to instantiate the global data ; ;iData - instantiate the initialised global data ;uData - instantiate the uninitialised global data ;sData - instantiate the initialised global string data ;bCode - instantiate the one-time start up executed code ;eCode - instantiate the one-time shut down executed code ;All macros are used like this: ; ; ; .idata ; { ; global_var1 rd 1 ; } ; ; ; .bcode ; { ; call MODULE_init_lut ; ... other arbitrary code ; } ; ; ; iData ; bCode ;initialised global data .idata_list equ macro .idata { local z .idata_list equ .idata_list,z macro z } macro iData { match data_list,.idata_list \{ irp instr,data_list \\{ instr \\} \} } ;uninitialised global data .udata_list equ macro .udata { local z .udata_list equ .udata_list,z macro z } macro uData { match data_list,.udata_list \{ irp instr,data_list \\{ instr \\} \} } ;global string data .sdata_list equ macro .sdata { local z .sdata_list equ .sdata_list,z macro z } macro sData { match data_list,.sdata_list \{ irp instr,data_list \\{ instr \\} \} } ;one time start-up initialisation/allocation code .bcode_list equ macro .bcode { local z .bcode_list equ .bcode_list,z macro z } macro bCode { match code_list,.bcode_list \{ irp instr,code_list \\{ instr \\} \} } ;one time shut-down deinitialisation/deallocation code .ecode_list equ macro .ecode { local z .ecode_list equ .ecode_list,z macro z } macro eCode { match code_list,.ecode_list \{ irp instr,code_list \\{ instr \\} \} } |
|||
21 Mar 2008, 12:18 |
|
pini 21 Mar 2008, 12:41
I found the original thread were you posted them (and it does *exactly* what I need). Thanks anyway.
|
|||
21 Mar 2008, 12:41 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.