In embedded systems, hardware registers are often accessed both as a full byte and as individual bit fields.
Your task is to define a union that overlays an 8-bit register with named bitfields in a deterministic and embedded-safe manner.
You must define a union Reg that contains:
raw of type uint8_tbits with the following fields:en : 1-bit enable flag (bit 0, least significant bit)mode : 3-bit mode field (bits 1–3)reserved : 4 bits (bits 4–7, unused)Assumptions (Explicit and Required):
The program will:
en and mode fields as numeric valuesInput
A single integer value N
0 ≤ N ≤ 255Output
Two numeric values printed on a single line:
en=<value> mode=<value>
Example:
Input
13
Output
en=1 mode=6 Explanation
13 = 0b00001101
bit 0 → en = 1
bits 1–3 → mode = 110b = 6
bits 4–7 → reserved
Input
13
Expected Output
en=1 mode=6