agg_bitfield_signed.c (455B)
1 /* A SIGNED bitfield: writing a value into a narrow signed field and reading it 2 * back sign-extends, which exercises the signed bitfield extract (sbfx-style) 3 * encoding distinct from the unsigned (ubfx) path. Here b is a 4-bit signed 4 * field holding -2 (read back as -2). 44 + (-2) = 42. */ 5 struct Bits { 6 int a : 8; 7 int b : 4; 8 }; 9 int test_main(void) { 10 volatile int va = 44, vb = -2; 11 struct Bits s; 12 s.a = va; 13 s.b = vb; 14 return s.a + s.b; 15 }