You are implementing firmware that manipulates a 32-bit memory-mapped control register.
To improve readability and safety, all register bit manipulation must be expressed using operator overloading, not raw bitwise expressions scattered throughout the firmware logic.
You are given a partially implemented program.
The program flow and logic are fixed.
Your task is to modify only the Register32 class so that the program:
Input / Program Flow:
The program receives:
SET x → set bit xCLEAR x → clear bit xThe initial register value is always 0.
Required Behavior:
Output Format:
Print exactly:
reg=<final_value>
Example
Input:
3
SET 0
SET 3
CLEAR 0 Explanation:
0SET 0 → register becomes 0000 0001 (decimal 1)SET 3 → register becomes 0000 1001 (decimal 9)CLEAR 0 → register becomes 0000 1000 (decimal 8)Output:
reg=8
Constraints:
x is guaranteed to be in the range 0–31main()The following lines must remain unchanged:
reg |= (1u << bit);
reg &= ~(1u << bit);Register32 class
Input
3 SET 0 SET 3 CLEAR 0
Expected Output
reg=8