flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > Need help on converting Masm's union!

Author
Thread Post new topic Reply to topic
BiMode



Joined: 14 Sep 2007
Posts: 14
Location: Thailand
BiMode 25 Jan 2009, 15:50
Hello guys,

I'm not good on fasm directives usage and trying to convert an union below which is Masm format.

Code:
IMAGE_SYMBOL STRUCT
    union N
        ShortName db 8 dup(?)
        struct Name1
            Short1 dd       ?
            Long1 dd        ?
        ends
        LongName dd 2 dup(?)
    ends
    Value dd                ?
    SectionNumber dw        ?
    Type1 dw                ?
    StorageClass db         ?
    NumberOfAuxSymbols db   ?
IMAGE_SYMBOL ENDS
    


Here is what my best,

Code:
struct IMAGE_SYMBOL
    N.ShortName             rb 8
    virtual at $-8
        Short               dd ?
        Long                dd ?
    end virtual
    virtual at $-8
        LongName            rd 2
    end virtual
    Value                   dd ?
    SectionNumber           dw ?
    Type                    dw ?
    StorageClass            db ?
    NumberOfAuxSymbols      db ?
ends
    


Any better form would be appriciate...
Post 25 Jan 2009, 15:50
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20445
Location: In your JS exploiting you and your system
revolution 25 Jan 2009, 15:54
You can try this:
Code:
struc IMAGE_SYMBOL {
    virtual
        N.ShortName         rb 8
    end virtual
    virtual
        N.Name1.Short1      dd ?
        N.Name1.Long1       dd ?
    end virtual
    N.LongName              rd 2
    Value                   dd ?
    SectionNumber           dw ?
    Type1                   dw ?
    StorageClass            db ?
    NumberOfAuxSymbols      db ?
}    
Post 25 Jan 2009, 15:54
View user's profile Send private message Visit poster's website Reply with quote
BiMode



Joined: 14 Sep 2007
Posts: 14
Location: Thailand
BiMode 27 Jan 2009, 11:48
Thx, I will try it.
Post 27 Jan 2009, 11:48
View user's profile Send private message Reply with quote
madmatt



Joined: 07 Oct 2003
Posts: 1045
Location: Michigan, USA
madmatt 29 Jan 2009, 05:48
you can also use the 'struct' macro, which also has a union macro
Example:

Code:
struct IMAGE_SYMBOL 
    union 
        N.ShortName         rb 8 
    ends 
    union 
        N.Name1.Short1      dd ? 
        N.Name1.Long1       dd ? 
    ends 
    N.LongName              rd 2 
    Value                   dd ? 
    SectionNumber           dw ? 
    Type1                   dw ? 
    StorageClass            db ? 
    NumberOfAuxSymbols      db ? 
ends    
Post 29 Jan 2009, 05:48
View user's profile Send private message Reply with quote
sinsi



Joined: 10 Aug 2007
Posts: 794
Location: Adelaide
sinsi 29 Jan 2009, 06:16
Unless you're going to access both parts, just make a struc for the one you do use.
Post 29 Jan 2009, 06:16
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20445
Location: In your JS exploiting you and your system
revolution 29 Jan 2009, 06:20
madmatt wrote:
you can also use the 'struct' macro, which also has a union macro
Example:

Code:
struct IMAGE_SYMBOL 
    union 
        N.ShortName         rb 8 
    ends 
    union 
        N.Name1.Short1      dd ? 
        N.Name1.Long1       dd ? 
    ends 
    N.LongName              rd 2 
    Value                   dd ? 
    SectionNumber           dw ? 
    Type1                   dw ? 
    StorageClass            db ? 
    NumberOfAuxSymbols      db ? 
ends    
I don't think that is correct. You need a union of ShortName. {Name1.Short1, Name1.Long1} and LongName. Where {} is a sub-union in the outer union.
Post 29 Jan 2009, 06:20
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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.