flat assembler
Message board for the users of flat assembler.

Index > Main > Define struct/macro

Author
Thread Post new topic Reply to topic
Uwar



Joined: 09 Oct 2009
Posts: 11
Uwar
Is it possible to create struct/macro which would works as 'db', 'dw', etc. directives? I mean something like a 'typedef' in C.

Code:
if expr
  struc da x{
    db x
  }
else
  struc dc x{
    dw x
  }
end if
    

and then
Code:
a da 0x0           ; works
b da 0x0, 0x0      ; fails
c da 'bytes', 0x0  ; fails
    
Post 13 Oct 2009, 14:57
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17715
Location: In your JS exploiting you and your system
revolution
Two problems:

1) you need square brackets.
Code:
  struc da [x]{ common
    db x
  }    


2) the if-else-endif block won't work the way you want. Both 'da' and 'dc' are always defined no matter what 'expr' is. This is a consequence of the preprocessor/assembler separation in fasm.
Post 13 Oct 2009, 15:01
View user's profile Send private message Visit poster's website Reply with quote
Uwar



Joined: 09 Oct 2009
Posts: 11
Uwar
revolution wrote:
Two problems:
2) the if-else-endif block won't work the way you want. Both 'da' and 'dc' are always defined no matter what 'expr' is. This is a consequence of the preprocessor/assembler separation in fasm.

Oh It was only my writing mistake. I had mean:
Code:
if expr
  struc da [x]{
    common
    db x
  }
else
  struc da [x]{
    common
    dw x
  }
end if
    

Thank's a lot, but there is still a one problem:
Code:
var da 'text', 0x0 ; fails when da is dw
    

Is it possible to define wide characters?
Post 13 Oct 2009, 15:20
View user's profile Send private message Reply with quote
r22



Joined: 27 Dec 2004
Posts: 805
r22
Code:
widechar du 'abcdefg'
    
Post 13 Oct 2009, 15:30
View user's profile Send private message AIM Address Yahoo Messenger Reply with quote
Uwar



Joined: 09 Oct 2009
Posts: 11
Uwar
Great Very Happy Thank's!
Post 13 Oct 2009, 15:35
View user's profile Send private message Reply with quote
Remy Vincent



Joined: 16 Sep 2005
Posts: 155
Location: France
Remy Vincent
Would it be possible to change this great topic to MACRO topics section ?

I have never been able to read MACRO topics Embarassed , and I will probably never be able to be involved with MACRO comments ... Embarassed

_________________
Groups lower your IQ
Post 13 Oct 2009, 15:49
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 GitHub, YouTube, Twitter.

Website powered by rwasa.