flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > undefine label

Author
Thread Post new topic Reply to topic
BAiC



Joined: 22 Mar 2011
Posts: 272
Location: California
BAiC
is there any way to remove a (psuedo)labels' definition such that
Code:
if ~ defined label
; ... code
end if    
evaluates true?

I'm working on templating which is sensitive to this type of pattern.

edit: defined, not eq (oops).
Post 21 Feb 2012, 18:44
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Not possible, but with the preprocessor's assistance you may come up with something near to that:
Code:
macro label arg
{
local d, l, m
; Check if already defined
   match =arg, arg\{d equ\}
   match d,d\{err 'Already defined'\}

   match name opts, arg
   \{
      label l opts
      name equ l
      m equ
   \}
   match m, m
   \{
      label l
      arg equ l
   \}
}
macro undefine name
{
   match =name, name\{err 'No such label'\}

   restore name
}

label foo byte

if ~defined foo
  display "1. Not defined"
end if

undefine foo

if ~defined foo
  display "2. Not defined"
end if    
However, forward referencing labels is not possible with this.
Post 21 Feb 2012, 21:01
View user's profile Send private message Reply with quote
l_inc



Joined: 23 Oct 2009
Posts: 881
l_inc
An option with forward referencing:
Code:
macro label [args]
{
  common local name
   match \name opts,args \{ name equ \name \}
    match =name,name \{ name equ args \}
    match \name,name
   \{
            if ~defined \name\#.undefined
                     label args
          end if
      \}
} 
macro undefine name
{
        local undef
 if defined name#.undefined & ~defined undef
             display 'The label "',`name,'" is already undefined',13,10
            err
 end if
      name#.undefined = 1
 undef = 1
}

undefine foo

label foo byte

if defined foo
 display 'Defined',13,10
else
   display 'Not defined',13,10
end if    
Post 21 Feb 2012, 23:46
View user's profile Send private message Reply with quote
BAiC



Joined: 22 Mar 2011
Posts: 272
Location: California
BAiC
Thanks Loco, l_inc.

I was looking to keep something like the file-based templates that I have but it looks like going back to 'struc' is the simplest option:

Code:
struc GlobalStruc
{ 
.code:
 };define actual code.

.localName GlobalStruc;define Single-Use struc.    

struc has the property that .code will be automatically appended to .localName allowing most of the code to be re-used as-is.
Post 22 Feb 2012, 12:07
View user's profile Send private message Visit poster's website 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.