flat assembler
Message board for the users of flat assembler.
 Home   FAQ   Search   Register 
 Profile   Log in to check your private messages   Log in 
flat assembler > Main > Defining entries of partial data size in structures

Author
Thread Post new topic Reply to topic
zhak



Joined: 12 Apr 2005
Posts: 421
Location: Belarus
Defining entries of partial data size in structures
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: 14488
Location: WTC Building 7
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


Powered by phpBB © 2001-2005 phpBB Group.

Main index   Download   Documentation   Examples   Message board
Copyright © 2004-2016, Tomasz Grysztar.