Hello,
It seems that bits in record in c++ are in reverse order than masm
here is a sample.Is it the same rule for all the record ? (8,16,32,64..)
Quote
typedef struct _LDT_ENTRY {
WORD LimitLow;
WORD BaseLow;
union {
struct {
BYTE BaseMid;
BYTE Flags1; // Declare as bytes to avoid alignment
BYTE Flags2; // Problems.
BYTE BaseHi;
} Bytes;
struct {
DWORD BaseMid : 8;
DWORD Type : 5;
DWORD Dpl : 2;
DWORD Pres : 1;
DWORD LimitHi : 4;
DWORD Sys : 1;
DWORD Reserved_0 : 1;
DWORD Default_Big : 1;
DWORD Granularity : 1;
DWORD BaseHi : 8;
} Bits;
} HighWord;
} LDT_ENTRY, *PLDT_ENTRY;
LDTBits RECORD rBaseHi:8,\
Granularity:1,\
Default_Big : 1,\
Reserved_0:1,Sys:1,\
LimitHi:4,Pres:1,\
Dpl:2,\
S_bit:1,\
Type1:4,\
yes, it's is fact that the bitrecord in masm is 100% reverse from that of C++. Why they use two different ways is beyond me, but everything in the Win32 API has to get declared in reverse order, e.g. MASM is high to low, C is low to high. Go figure.
For C, from http://msdn2.microsoft.com/en-us/library/ewwyfdbe.aspx
"The ordering of data declared as bit fields is from low to high bit, as shown in the figure above."
from the MASM programmers guide:
"The first field in the declaration always goes into the most significant bits of the record. Subsequent fields are placed to the right in the succeeding bits"
-alan