flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > combine variables at one place... |
Author |
|
revolution 17 Apr 2008, 13:52
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 \\} \} } |
|||
17 Apr 2008, 13:52 |
|
AlexP 17 Apr 2008, 13:56
?! I think that's a little much than he required, but good macro(s). Does he want a more OOP-style of initializing variables? He may try this:
Code: macro new name,string { name db string } Note this is just a high-level view of what the macro would look like, I highly doubt the one I just posted would actually work. I can't test it now, school computers... EDIT: Oh, I see he would like them to be grouped in one section. I believe the only way to do this is to not use the macro in the middle of the code, but group them like so: Code: section '.data' data readable writeable .. new a 'asd' new b 'asdflas' .. ; would give .. a db 'asd' b db 'asdflas' .. |
|||
17 Apr 2008, 13:56 |
|
revolution 17 Apr 2008, 14:05
AlexP wrote: ?! I think that's a little much than he required, but good macro(s). Does he want a more OOP-style of initializing variables? |
|||
17 Apr 2008, 14:05 |
|
AlexP 18 Apr 2008, 02:58
Well then.. fine... and I did not call your macros OOP-style. I simply stated that it looks like (from his 'new' keyword) that he was trying to build a more OOP-style ASM programming. I may make use of those macros, I have an idea...
|
|||
18 Apr 2008, 02:58 |
|
qeos 18 Apr 2008, 12:31
2revolution, I think this is what I need.. thank
|
|||
18 Apr 2008, 12:31 |
|
qeos 18 Apr 2008, 12:58
Code: .gvar_list equ macro vars { local z .gvar_list equ .gvar_list,z macro z } macro globalVar { match var_list,.gvar_list \{ irp instr,var_list \\{ instr \\{ \} } Code: vars { asdf db 'asdfasdf' } globalVar Quote: flat assembler version 1.67.26 (1031068 kilobytes memory) I dont understand where is trouble? |
|||
18 Apr 2008, 12:58 |
|
revolution 18 Apr 2008, 13:12
qeos wrote:
Code: .gvar_list equ macro vars { local z .gvar_list equ .gvar_list,z macro z } macro globalVar { match var_list,.gvar_list \{ irp instr,var_list \\{ instr \\} \} } |
|||
18 Apr 2008, 13:12 |
|
qeos 18 Apr 2008, 13:49
big thanks!
|
|||
18 Apr 2008, 13:49 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.