flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > [Help]:String table macro |
Author |
|
revolution 25 Dec 2013, 18:20
You might be interested in this topic:
http://board.flatassembler.net/topic.php?t=12012 'index' is not a text equate so it is always concatenated as 'index' during preprocessing. The value of index is not converted to ASCII by the macro since it is an assembly time variable. |
|||
25 Dec 2013, 18:20 |
|
baldr 25 Dec 2013, 19:10
typedef,
Be careful when you mix assembly & preprocessor. |
|||
25 Dec 2013, 19:10 |
|
typedef 25 Dec 2013, 19:20
baldr wrote: typedef, I wouldn't know because I have limited knowledge of FASM macros. Most of the macro examples are just mangled together without proper 'vocab' list. At least this one by vid is somewhat fair: http://bos.asmhackers.net/docs/FASM%20tutorial/preproc.html Anyway, someone just fix my macro and I'll study it...and I will call it a day. |
|||
25 Dec 2013, 19:20 |
|
revolution 25 Dec 2013, 19:26
typedef wrote: Anyway, someone just fix my macro and I'll study it...and I will call it a day. Anyhow a macro is already written for you in the link I posted above. Just use it instead of your broken one. Fixing your broken macro would require too much effort. |
|||
25 Dec 2013, 19:26 |
|
typedef 25 Dec 2013, 19:59
revolution wrote:
Hahaha now look who's being lazy I hate using people's code when I can get an understanding of what the code does and come up with my own ideas. To say the least, you are giving me a fish instead of a fishing pole. If you mend this code rev, I'll buy you something. Your linked example doesn't seem to create what I want or maybe it's just too cryptic. I want to define strings where their labels are defined by the macro itself but at the same time I know which string is which. instead of having to write this Code: s1 db 'string_one',0 s2 db 'string_two',0 ... s10000 db 'string_10k',0 I want to do this Code: string_table 'string_one','string_two',\... ,'string_10k' I don't want anything else in between them. Just that format and when I want to use them Code: invoke MessageBoxW,0,s106,0,0 |
|||
25 Dec 2013, 19:59 |
|
baldr 25 Dec 2013, 20:14
Anybody have good name for iteration number inside irps (apart of %)?
|
|||
25 Dec 2013, 20:14 |
|
revolution 25 Dec 2013, 20:16
typedef wrote: Hahaha now look who's being lazy |
|||
25 Dec 2013, 20:16 |
|
typedef 25 Dec 2013, 21:04
It's okay. I'll type the same thing 10,000 times while crying blood.
Merry Christmas or Happy Evolution day. Wish me luck. |
|||
25 Dec 2013, 21:04 |
|
bitRAKE 26 Dec 2013, 08:06
I like the following method used by baldr and others to perform calculations with the preprocessor:
Code: struc equ! expr { rept 1 value:expr \{ restore . . equ value \} } Code: macro string_table [value] { common local index index equ 0 forward index equ! index+1 match A,index \{ s\#A: db value,0 \} } Why is the MATCH needed? : The concatenation doesn't resolve index to it's value (page 97 of the manual explains symbolic replacement). Sometimes your posts are so lazy that you just seem like a troll. Happy Holidays anyhow. _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
26 Dec 2013, 08:06 |
|
m3ntal 26 Dec 2013, 11:45
You need an array of pointers to texts/strings? To access like this? mov eax, [s+ecx*4] ; ?
Code: macro texta name, [t] { common ; begin... name: ; create label forward ; first... local l ; create array of pointers dd l ; to text addresses forward ; then... l db t, 0 ; create array of strings } Code: ; create: texta fruits,\ 'Apple', 'Banana', 'Cherry', 'Grape' ; access in code: mov ecx, 2 ; index='Cherry' mov eax, [fruits+ecx*4] ; eax=address of text To prefix the index with "s" doesn't make sense: s0, s1, s2, etc. In that case, why not just use the index? For descriptive IDs, try this: Code: ; create text array with IDs and length (.$) macro texti name, [t] { common name: ; begin ?n=0 ; index=0 forward ; create array of pointers local l dd l forward define ?s 0 match a==b, t \{ l db b, 0 a=?n ?n=?n+1 define ?s 1 \} if ?s eq 0 'Syntax error' end if common name#.$=?n } Code: ; create: texti fruits,\ ID.APPLE='Apple', ID.BANANA='Banana',\ ID.CHERRY='Cherry', ID.GRAPE='Grape' ; access is the same: mov ecx, ID.CHERRY ; index=2 mov eax, [fruits+ecx*4] ; eax=address of text Quote: explain also why index is not being resolved to any number Code: local index ; ... index=1 ; numeric constant index equ 1 ; or equate (but not both) Quote: Not an expert in macros... I have limited knowledge of FASM macros |
|||
26 Dec 2013, 11:45 |
|
Roman 13 Jan 2014, 13:26
Be cool do like this:
Code: texti fruits,\ ID.APPLE='Apple',AppleProc, ID.BANANA='Banana',BananaProc,\ And then do: Code: RunProc fruits,ID.APPLE RunProc fruits,ID.BANANA Or cool create parallel threads ! Code: RunThread fruits,ID.APPLE RunThread fruits,ID.BANANA |
|||
13 Jan 2014, 13:26 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.