flat assembler
Message board for the users of flat assembler.
Index
> Main > Add to FASM textual constant(lack of better name) |
You think FASM should have such an operator? | |||||||||||||||||||||
|
|||||||||||||||||||||
Total Votes : 10 |
Author |
|
vid 13 Jan 2005, 14:32
there is no text processed at assembly stage, because before it (and after preprocessing) there is a "parser" stage where text is parsed into internal format (for example address of structure describing label instead of label name, or address of instruction/directive handler instead of it's name). What you want just isn't possible, sorry.
But there may be other solutions, what would you use such operator for? |
|||
13 Jan 2005, 14:32 |
|
scientica 13 Jan 2005, 15:43
You're not thinking about something like the '#' operator?
fasm.txt (the fasm manual), 2.3.3 Macroinstructions: Code: The "#" operator can be also used to concatenate two quoted strings into one. Also conversion of name into a quoted string is possible, with the "`" operator, which likewise can be used inside the macroinstruction. It convert the name that follows it into a quoted string - but note, that when it is followed by a macro argument which is being replaced with value containing more than one symbol, only the first of them will be converted, as the "`" operator converts only one symbol that immediately follows it. Here's an example of utilizing those two features: macro label name { label name if ~ used name display `name # " is defined but not used.",13,10 end if } |
|||
13 Jan 2005, 15:43 |
|
MCD 13 Jan 2005, 17:03
I think that textual constants are really needed (sometimes), and that those will solve many different problems at once.
But the problem with Quote: You're not thinking about something like the '#' operator? Unfortunately, this would require a bigger change of Fasm's parser/assembler. |
|||
13 Jan 2005, 17:03 |
|
beppe85 14 Jan 2005, 15:38
vid, I don't know if it need to be done exactly in assembly stage, but at least after if's processing. Later I'll post some code demonstrating the problem.
scientica, no, I'm not using strings. But if there's a way to dequote strings, it could be used, but I think there isn't, like vid pointed. MCD, can you show some other use? It would help to convince people. Thank you all, and I'm still waiting for the reply of the guy voting there's another way to circunvent this. |
|||
14 Jan 2005, 15:38 |
|
beppe85 14 Jan 2005, 21:54
This is what I was coding(not handle all cases yet):
Code: macro _assign_parameters [Param] { common local ..param_count, ..iParam, ..base_reg ..param_count = 0 if defining_naked = 1 ..base_reg = esp else ..base_reg = ebp + 4 end if if ~ Param eq forward ..param_count = ..param_count + 1 ..iParam = ..param_count * 4 + 4 if defining_register = 1 if ..param_count = 1 Param = eax else if ..param_count = 2 Param = edx else if ..param_count = 3 Param = ecx else end if else Param = [..base_reg + ..iParam] else Param = [..base_reg + ..iParam] end if common end if param_count.#CurrentClass#.#CurrentMethod = ..param_count params.#CurrentClass#.#CurrentMethod equ Param } Obviously it doesn't compiles. It complains about the registers and memory locations being assigned to names. If I use equ it compiles but ignores all equ's but the last. When a parameter name is used inside a routine, it gets replaced by its actual location, either register or stack. |
|||
14 Jan 2005, 21:54 |
|
MCD 18 Jan 2005, 15:19
I personally think that textual constants should abolutely be added, when needed. And I think that this poll should helps to find out if they are needed enough. I am currently seeking a way to implement them into Fasm, on my own as usual .
But I don't think I will succeed within a resonable amount of time, like I abondaned the try to add a size-detecting operator. But I'm also open to any suggestions by other. |
|||
18 Jan 2005, 15:19 |
|
beppe85 18 Jan 2005, 15:49
I fully agree with you, MCD. I solved my problem with the macro ifdef as devised by Privalov, but in a hardly obvious manner. I think textual constant gives to the programmer substantial expressivity, so it should have a chance.
Good luck, MCD, unfortunately I do not have the knowledge of the implementation of FASM, I'll not be of much help. |
|||
18 Jan 2005, 15:49 |
|
MCD 18 Jan 2005, 16:22
You know, implementing such things require you to take several days/weeks of time, where you will mainly be analyzing the code. I mean, Fasm is rather good written (i've seen worse) and I'm quiet experienced coder (I think so, 8 years), but added such a fundamental thing would be a heck of a lot easier if there were some more docs on the Fasm internals. Still the GTFI has only docs for the interface/preprocessor, and everything else must be analyzed by oneself, a difficult task!
|
|||
18 Jan 2005, 16:22 |
|
Tomasz Grysztar 18 Jan 2005, 17:56
The vid already told why it's not possible not implement such features in the assembler module. The only solution would be to add some preprocessor-stage control directives (like "if" or "repeat") and this would need also to have some preprocessor-stage expression evaluators to be implemented, etc. So it's almost like the whole preprocessor would have to be rebuilt, and I would rather recommend you to make your own pre-preprocessor (it does really mean: some high level compiler generating fasm code) for such purposes.
|
|||
18 Jan 2005, 17:56 |
|
MCD 24 Jan 2005, 17:03
Yeap, Privalov, you're right. The first analysis of the preprocessor of this task (I did the recent week) showed exactly what you said: The entire preprocessor should be rebuild in such case. Unfortunately I don't have such amount of time anymore, since my civil service will start very soon. Furthermore, when adding textual constants, one must also add lots of operators for it, and I don't know finding keywords/operators that would fit well enough in the whole concept of Fasm. I think that such a big decision should be up to you, Privalov, and perhaps to the whole Fasm public.
|
|||
24 Jan 2005, 17:03 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.