You should never rely on how the compiler poses your structure in memory. There are ways to do what you want with one task, but I will not recommend or tell you.
:
static inline void to_id(struct CPUid *id, uint32_t value)
{
id->Stepping = value & 0xf;
id->Model = (value & (0xf << 4)) >> 4;
id->FamilyID = (value & (0xf << 8)) >> 8;
id->Type = (value & (0x3 << 12)) >> 12;
id->Reserved1 = (value & (0x3 << 14)) >> 14;
id->ExtendedModel = (value & (0xf << 16)) >> 16;
id->ExtendedFamilyID = (value & (0xff << 20)) >> 20;
id->Reserved2 = (value & (0xf << 28)) >> 28;
}
static inline uint32_t from_id(struct CPUid *id)
{
return id->Stepping
+ ((uint32_t)id->Model << 4)
+ ((uint32_t)id->FamilyID << 8)
+ ((uint32_t)id->Type << 12)
+ ((uint32_t)id->Reserved1 << 14)
+ ((uint32_t)id->ExtendedModel << 16)
+ ((uint32_t)id->ExtendedFamilyID << 20)
+ ((uint32_t)id->Reserved2 << 28);
}