3 ms·
Yes, what bitfields do on the bus is very undefined. Admittedly, a compiler is free to implement a dereference of uint32_t by loading four separate bytes, too,
by JoachimSchipper 8y ago
Yes, what bitfields do on the bus is very undefined.
Admittedly, a compiler is free to implement a dereference of uint32_t by loading four separate bytes, too, hence the imprecise "very undefined" in the first line...
- tripletao 8y agoI just tried this with IAR for Cortex-M3. I didn't check thoroughly, but so far it looks like right-aligned bitfields of eight bits or less generate an LDRB (8-bit). All other bitfields generate an LDR (32-bit), even if they lie entirely within a byte. I see the makings of a fun trick to play on a colleague. I don't see anything I'd be too inclined to use in production code.