flat assembler
Message board for the users of flat assembler.

Index > Main > Defining entries of partial data size in structures

Author
Thread Post new topic Reply to topic
zhak



Joined: 12 Apr 2005
Posts: 501
Location: Belarus
zhak 31 Oct 2016, 23:44
If a C header defines a structure as
Code:
struct MY {
    UINT32 Length:24;
    UINT32 Type:8;
}
    


meaning the upper three bytes of DWORD are Length, and the low byte of a DWORD is type, how would you implement such struct in fasm?

I thought it could be
Code:
struct MY
    Length rb 3
    Type rb 1
ends
    

Or maybe there's a more elegant way?
Post 31 Oct 2016, 23:44
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20451
Location: In your JS exploiting you and your system
revolution 31 Oct 2016, 23:55
I don't know what you consider "elegant". You might also want to place a dword covering alias:
Code:
struct MY
        union
                value rd 1
                struct
                        Length rb 3
                        Type rb 1
                ends
        ends
ends    
Post 31 Oct 2016, 23:55
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.