flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > delayed code choice question

Author
Thread Post new topic Reply to topic
IronFelix



Joined: 09 Dec 2004
Posts: 141
Location: Russia, Murmansk region
IronFelix
Hi, all!
Please help me with such thing: suppose you have a set of functions which
can be coded in 2 ways (for example), and the choice of implementation depends on number of such functions - if it is only one such function in code first implementation should be used, and if more - another one. Is it possible to make such choice exactly where such kind of functions is declared, not after all declarations, in order to get its code at the place needed?
Thanks.

_________________
Flat Assembler is the best!
Post 31 Jan 2009, 20:49
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7734
Location: Kraków, Poland
Tomasz Grysztar
Just use forward-reference to access the symbolic constant defined at the end of code. Something like:
Code:
macro func
{
  counter@func = counter@func + 1
  if total@func > 1
    ; implementation 2
    nop
  else
    ; implementation 1
  end if
}

counter@func = 0






; program body


func



; program end

total@func = counter@func    

Or did I misunderstood what do you need?
Post 31 Jan 2009, 21:07
View user's profile Send private message Visit poster's website Reply with quote
IronFelix



Joined: 09 Dec 2004
Posts: 141
Location: Russia, Murmansk region
IronFelix
Thank for so quick reply Tomasz, but I need not exactly this - is it possible to get "implementation2" for all functions if counter@func > 1,
not "implementation1" for the first, and "implementation2" for rest? And only if "func" is the one in code - use "implementation1".
Post 31 Jan 2009, 21:24
View user's profile Send private message Reply with quote
IronFelix



Joined: 09 Dec 2004
Posts: 141
Location: Russia, Murmansk region
IronFelix
Sorry, this work as needed. Thanks a lot Tomasz.
Post 31 Jan 2009, 21:29
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 YouTube, Twitter.

Website powered by rwasa.