flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > Naming "unions"

Author
Thread Post new topic Reply to topic
alorent



Joined: 05 Dec 2005
Posts: 201
alorent
Hello,

I was wondering if it's possible something like the following in FASM:


Code:
union parameter
   t1   dd  ?
   t2   dw  ?
   t3   db  ?
ends 

struct MyStruct 
 
   id          dd 0
   param1  parameter 
   param2  parameter 

ends    


I have seen in all union examples that the union is defined inside the struct, but not defining the union outside and use it later in a struct.

Anyway, if there is a workaround in FASM for the above example, how would I access to the elements in the union? Something like:

mov eax, [ebx + MyStruct.param1.t1] ????

Thanks!
Post 26 May 2010, 10:57
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr
alorent,

Indeed union is a struct macro feature. You can use
Code:
struct parameter
   union
      t1   dd  ?
      t2   dw  ?
      t3   db  ?
   ends
ends 

struct MyStruct 
   id          dd 0
   param1  parameter 
   param2  parameter 
ends    
to achieve the desired effect. Section 1.1 of Win32 headers' manual contains all the needed info.
Post 26 May 2010, 13:01
View user's profile Send private message Reply with quote
alorent



Joined: 05 Dec 2005
Posts: 201
alorent
baldr, thanks a lot! Damn! don't know how it didn't realised about that Smile

Thanks again!!! Very Happy
Post 26 May 2010, 15:51
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.

Powered by rwasa.