flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > [fasmg] do purge or restore restores struc definition?

Author
Thread Post new topic Reply to topic
zhak



Joined: 12 Apr 2005
Posts: 490
Location: Belarus
zhak
I'm trying to redefine standard data types to use only inside macro, and then restore them back:
Code:
macro my? name
  struc db? arg
    label .
    match ?, arg
      rb 1
    else match n =dup? ?, arg
      rb n
    else match n =dup? (?), arg
      rb n
    else
      err "Invalid element data type definition"
    end match
    .__length = $ - .
    .__size = 1
  end struc
  
  macro end?.my?
    end struc
    . . .
    purge db?
    ;restore db
  end macro
    struc my
      . . .
end macro
    

however, purge or restore doesn't seem to undefine struc, because when I do
Code:
my OWN
  a db ?
end my

b db 1

some OWN a:3
    

I get custom error "Invalid element data type definition" for `b db 1`. Looks like `end my` doesn't restore the symbol.
Post 11 Feb 2017, 12:16
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7752
Location: Kraków, Poland
Tomasz Grysztar
It is the same as in fasm 1, for STRUC macros use RESTRUC instead of PURGE.

PURGE is for instruction class symbols (macros), RESTORE for expression class ones, and RESTRUC is for labeled instruction class (STRUC macros). You can have symbols with the same name in all three classes and each of them is going to work in the appropriate context.
Post 11 Feb 2017, 12:38
View user's profile Send private message Visit poster's website Reply with quote
zhak



Joined: 12 Apr 2005
Posts: 490
Location: Belarus
zhak
Ah, I see. I thought struc belongs to instruction class, too
Post 11 Feb 2017, 12:50
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.