flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > how to separate strings and pointers |
Author |
|
revolution 01 Jun 2010, 19:54
Code: strtbl Table1,\ 'String1',\ 'String2',\ 'String3',\ 'String4' |
|||
01 Jun 2010, 19:54 |
|
qeos 01 Jun 2010, 20:17
2revolution this is no what I need
I wrote this: Code: .dvars equ .dstrs equ db 0 macro cdata name, [string]{ local z .dvars equ .dvars,name dd z .dstrs equ .dstrs,z db string } macro ddata{ match names,.dvars \{ irp inames,names \\{ inames \\} \} match names,.dstrs \{ irp inames,names \\{ inames, 0 \\} \} } cdata data01, 'str1' cdata data02, 'str2' rb 0x100-$ DataS: ddata It's a bit ugly, but it works Thanks to Tomasz Grysztar for his programm. They show preprocessed datas as: Quote: data01 dd z?0000000 |
|||
01 Jun 2010, 20:17 |
|
LocoDelAssembly 01 Jun 2010, 21:35
Quote:
It is worth mentioning however that the macro you extracted from the documentation puts the data as you requested in your first post and not as you reported how it works. From your new code I assume you want to provide a symbol for each pointer? In that case you could use this: Code: macro strtbl name, [label,string] { forward dd label forward label db string,0 } Usage example: Code: strtbl DataS,\ alpha, 'alpha',\ someName, 'delta' |
|||
01 Jun 2010, 21:35 |
|
qeos 01 Jun 2010, 21:45
LocoDelAssembly wrote: It is worth mentioning however that the macro you extracted from the documentation puts the data as you requested in your first post and not as you reported how it works. I have bad english.. sorry.. LocoDelAssembly wrote:
Your code puts the data in local places, and my code makes it possible to declare variables at different locations.. and then assemble all in one place .. |
|||
01 Jun 2010, 21:45 |
|
baldr 02 Jun 2010, 07:02
qeos wrote: Thanks to Tomasz Grysztar for his programm.
|
|||||||||||
02 Jun 2010, 07:02 |
|
cod3b453 02 Jun 2010, 09:12
Thanks baldr - seriously, I tried to compile it before reading your reply and failed
|
|||
02 Jun 2010, 09:12 |
|
baldr 02 Jun 2010, 09:30
cod3b453,
That small utility saves me several hundred times: unless Tomasz will make FASM write .fas even if assembly is failed, we have to stick with it. Due to reworked .Inc structure it contains unused code, though. |
|||
02 Jun 2010, 09:30 |
|
qeos 09 Mar 2011, 04:16
I has new way to define strings and collect they at the end of binary. But I get new trouble with macro and I dont know how it made..
I has this macro: Code: .d_str_data equ macro idata_s name, [var]{ local pdata .d_str_data equ .d_str_data name db var, } macro ddata{ common .d_str_data equ .d_str_data db '' match names,.d_str_data \{ irp inames,names \\{ inames, 0 \\} \} } And used code: Code: idata_s Strings_init_heap_0,<'Found '> idata_s Strings_init_heap_1,<' Mb of memory', db 10, db 13> ddata and I get code (by fasmpre): Code: Strings_init_heap_0 db 'Found ',0 Strings_init_heap_1 db ' Mb of memory',0 db 10,0 db 13,0 db '',0 It is a little not that that is necessary for me, since it is necessary for me in such kind: Code: Strings_init_heap_0 db 'Found ',0 Strings_init_heap_1 db ' Mb of memory',10,13,0 Whether there is any way for use of a divider a comma, but something else? or how still it is possible to collect all line variables in one place? |
|||
09 Mar 2011, 04:16 |
|
edfed 09 Mar 2011, 04:34
prefer
crlf equ 10,13 |
|||
09 Mar 2011, 04:34 |
|
qeos 09 Mar 2011, 17:34
yep! thanx, it works!
|
|||
09 Mar 2011, 17:34 |
|
edfed 09 Mar 2011, 18:19
but in asm, one important thing is the separation of declaration and referencing.
it is not a limitation, but a very good feature that lets you declare a lot of strings in some data section, and only reference those you need. and more... create a dictionary, and reference the words you need in other parts of the code. it is some asm basics. what can be good in this idea of referencing strings is a macro to generate an equate file, containing all references for the strings inside the compiled string file. then, for this kind of file: Code: string db "string",0 hello db "hello",0 world db "world",0 assembler db "assembler",0 obtain a equate file like this: Code: string equ 0 hello equ 7 world equ 13 assembler equ 19 and then, be able to just reference everystrings from the dictionary that is supposed to be loaded somewhere in ram. a sort of text library, something more like the real definition of what is a library...a group of texts. |
|||
09 Mar 2011, 18:19 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.