Author Topic: Structure bit fields in NASM ?  (Read 10389 times)

Offline Mathi

  • Jr. Member
  • *
  • Posts: 82
  • Country: in
    • Win32NASM
Structure bit fields in NASM ?
« 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.

Offline Bryant Keller

  • Forum Moderator
  • Full Member
  • *****
  • Posts: 360
  • Country: us
    • About Bryant Keller
Re: Structure bit fields in NASM ?
« Reply #1 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.

About Bryant Keller
bkeller@about.me