flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > Passing struct name to macro

Author
Thread Post new topic Reply to topic
SFeLi



Joined: 03 Nov 2004
Posts: 140
SFeLi
Hi. I need to define a huge amount of labels of different types. I used a simple macro below but it doesn’t work with structs. Is there any way to define Bar as Xyzzy structure using such macro?
Code:
        format  binary
        include 'win32a.inc'

struct Xyzzy
 n dd ?
ends

macro def name*,addr*,type*
{
  if type eqtype 0
    label name at addr
  else if type eqtype byte
    label name type at addr
  elseif `type eq 'code'
    label name at addr
  else
    virtual at addr
      name type
    end virtual
  end if
}

def Foo,0x123456,dword
def Bar,0xabcdef,Xyzzy
    


Edit: correct macro:
Code:
macro def name*,addr*,type*
{
  if ~defined(sizeof.#type) & (type eqtype 0)
    label name at addr
  else if (type eqtype byte)
    label name type at addr
  else if `type eq 'code'
    label name at addr
  else
    virtual at addr
      name type
    end virtual
  end if
}
    


Last edited by SFeLi on 24 Mar 2009, 08:33; edited 2 times in total
Post 23 Mar 2009, 12:01
View user's profile Send private message Reply with quote
SFeLi



Joined: 03 Nov 2004
Posts: 140
SFeLi
No ideas? Is it impossible?
Post 24 Mar 2009, 07:54
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7756
Location: Kraków, Poland
Tomasz Grysztar
Your "if type eqtype 0" becomes "if Xyzzy eqtype 0" and is interpreted by preprocessor as a definition of Xyzzy structure with "if" name. To avoid this, you can rearrange the condition, or do it like:
Code:
  if (type eqtype 0)    
Post 24 Mar 2009, 08:00
View user's profile Send private message Visit poster's website Reply with quote
SFeLi



Joined: 03 Nov 2004
Posts: 140
SFeLi
Ashamed. Thank you. It works with this condition:
Code:
if ~defined(sizeof.#type) & (type eqtype 0)    
Post 24 Mar 2009, 08:30
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.