flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > How to distinguish the label and constant?

Author
Thread Post new topic Reply to topic
CandyMan



Joined: 04 Sep 2009
Posts: 413
Location: film "CandyMan" directed through Bernard Rose OR Candy Shop
CandyMan 17 Jan 2013, 13:43
How to distinguish the label and constant?
Code:
ThisIsConst = 10

ThisIsLabel:

        if ThisIsLabel eqtype 0
        end if
    

_________________
smaller is better
Post 17 Jan 2013, 13:43
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 17 Jan 2013, 15:44
CandyMan,

Not an easy task (they're so closely related). The most I can offer to try is relativeto operator and object output format.
Code:
format COFF
ThisIsConst = 10
ThisIsLabel:

if ThisIsConst relativeto $
  display "Label"
else
  display "Constant"
end if    
Post 17 Jan 2013, 15:44
View user's profile Send private message Reply with quote
shutdownall



Joined: 02 Apr 2010
Posts: 517
Location: Munich
shutdownall 17 Jan 2013, 18:55
Strange request - for what do you need it exactly ?

You should know if you define a label or a constant. Very Happy
Post 17 Jan 2013, 18:55
View user's profile Send private message Send e-mail Reply with quote
CandyMan



Joined: 04 Sep 2009
Posts: 413
Location: film "CandyMan" directed through Bernard Rose OR Candy Shop
CandyMan 18 Jan 2013, 13:19
Thanks!
Post 18 Jan 2013, 13:19
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20334
Location: In your JS exploiting you and your system
revolution 19 Jan 2013, 16:08
shutdownall wrote:
Strange request - for what do you need it exactly ?
For a macro maybe?
Post 19 Jan 2013, 16:08
View user's profile Send private message Visit poster's website Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 19 Jan 2013, 19:28
revolution,

Surely for a macro (but if doesn't fit well). There should be some synergy between preprocessor and interpreter (at least we have rept for some calc), probably in 2.0 it'll prosper wildly. Wink
Post 19 Jan 2013, 19:28
View user's profile Send private message Reply with quote
seapoint



Joined: 25 May 2013
Posts: 8
seapoint 06 Jun 2013, 21:31
Recently I had a similar problem, but I wanted to discern between normal labels and everything else. The simplest way is just to use regexp in python

Code:
import sys, re

def main(argv):
    if len(argv) < 3:
        print "usage: %s <source asm> <output asm>" % argv[0]
    else:
        output_file = open(argv[2], 'w')
        input_file = open(argv[1], 'r')
        out = add_labels(input_file.read())
        output_file.write(out)

def add_labels(source):
    labels = [label[:-1] for label in re.findall("\w+:", source)]
    return "_ALL_LABELS equ %s\n" % ",".join(labels) + source 

if __name__ == "__main__":
    main(sys.argv)

    


then you can just use if arg in <_ALL_LABELS>.

For dynamic labels (generated by macros) I guess you can first preprocess asm source using fasm and get all labels from that?

It would be great if fasm was written in python, with all "macros" as full python code. Literally everything would be possible, and it would probably be much faster, too. Maybe someday...
Post 06 Jun 2013, 21:31
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.