NASM - The Netwide Assembler

NASM Forum => Programming with NASM => Topic started by: Mathi on October 01, 2012, 10:29:57 AM

Title: Structure bit fields in NASM ?
Post by: Mathi on October 01, 2012, 10:29:57 AM
Hi All,

Is there any sane way to implement structure bitfields similar to C. ?
//sizeof(abc) is 4 bytes though it has 3 ints..
struct abc
{
   unsigned int  a : 4;
   unsigned int  b : 24;
   unsigned int  c : 4;
};

I was thinking of defining bit masks for individual members. But wanted to check if there are other elegant ways.

Thanks,
Mathi.
Title: Re: Structure bit fields in NASM ?
Post by: Bryant Keller on October 01, 2012, 09:30:42 PM
That is more of a C language construct to prevent the compiler from treating members as whole values and force the use of masks.