There is a certain structure with bit fields. Let's say
struct _example{ unsigned f10:1; unsigned f11:1; unsigned f2:2; unsigned f4:4; unsigned f8:8; unsigned f16:16; }; When accessing f10 in the form a10 | = 1, the code orb $1,(%rcx) orl $1,(%rcx) , and orl $1,(%rcx) needed. Register% rcx for example, contains the address of the beginning of the structure.
You can declare the corresponding variables volatile, but this solution is suitable for the very first field.
If you think about it, the compiler cannot determine the boundaries of 32-bit words in the structure, therefore it refers to bytes. https://gcc.godbolt.org/z/17JQWM
orb $1,(%rcx). - HolyBlackCat 4:26 pmint set_enable() { volatile unsigned int *p = (__typeof__(p))&ex; return *p |= 1; }int set_enable() { volatile unsigned int *p = (__typeof__(p))&ex; return *p |= 1; }int set_enable() { volatile unsigned int *p = (__typeof__(p))&ex; return *p |= 1; }and the compiler will hear you - avpunsigned intinstead of the whole structure and set values to bit masks. Only need to describe a bunch of masks. - Adokenai