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?
Yes, would be great
40%
 40%  [ 4 ]
No, there are ways to circunvent the problem
30%
 30%  [ 3 ]
No, this problem doesn't worth that
30%
 30%  [ 3 ]
Total Votes : 10

Author
Thread Post new topic Reply to topic
beppe85



Joined: 23 Oct 2004
Posts: 181
beppe85
Those who are reading my saga in the Macroinstructions section, are aware of the problem that I am having.

I think that it would be very useful if there was an operator of the type "textual constant", processed at assembly stage, a mix of equ with =.

I ask If you think so too.

PS: If you answer the second option, please I want to know your solution
Post 12 Jan 2005, 19:46
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
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?
Post 13 Jan 2005, 14:32
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
scientica
Retired moderator


Joined: 16 Jun 2003
Posts: 689
Location: Linköping, Sweden
scientica
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
     }    
Post 13 Jan 2005, 15:43
View user's profile Send private message Visit poster's website Reply with quote
MCD



Joined: 21 Aug 2004
Posts: 604
Location: Germany
MCD
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?
is that they are processed at preprocessor stage(like vid said).

Unfortunately, this would require a bigger change of Fasm's parser/assembler.
Post 13 Jan 2005, 17:03
View user's profile Send private message Reply with quote
beppe85



Joined: 23 Oct 2004
Posts: 181
beppe85
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.
Post 14 Jan 2005, 15:38
View user's profile Send private message Reply with quote
beppe85



Joined: 23 Oct 2004
Posts: 181
beppe85
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.
Post 14 Jan 2005, 21:54
View user's profile Send private message Reply with quote
MCD



Joined: 21 Aug 2004
Posts: 604
Location: Germany
MCD
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 Wink.
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. Razz
Post 18 Jan 2005, 15:19
View user's profile Send private message Reply with quote
beppe85



Joined: 23 Oct 2004
Posts: 181
beppe85
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.
Post 18 Jan 2005, 15:49
View user's profile Send private message Reply with quote
MCD



Joined: 21 Aug 2004
Posts: 604
Location: Germany
MCD
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!
Post 18 Jan 2005, 16:22
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7802
Location: Kraków, Poland
Tomasz Grysztar
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.
Post 18 Jan 2005, 17:56
View user's profile Send private message Visit poster's website Reply with quote
MCD



Joined: 21 Aug 2004
Posts: 604
Location: Germany
MCD
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.
Post 24 Jan 2005, 17:03
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.