You are implementing a simulated 8-bit control register where each bit controls a feature. Rather than using masks, you’ll use a bitfield struct to access individual bits.
The register layout is as follows:
Bit | Field | Size |
0 | enable | 1 |
1–2 | mode | 2 |
3 | interrupt | 1 |
4–7 | reserved | 4 |
Your task is to:
Assume:
Example-1
Input: 1 2 1
Output: 13
Explanation:
Example-2
Input: 0 0 1
Output: 8
Binary = 00001000
Input
1 2 1
Expected Output
13