Your question is Bitwise Status Flag Extraction. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
An Analog Devices ADuCM3029 status register contains control and diagnostic bits. Implement a function that inverts only the bits selected by an inversion mask, preserves every other bit, and extracts named status flags from the original register value.
Implement process_register(register_value, width, invert_mask, flag_masks).
register_value is a non-negative integer containing the register contents.width is the register width in bits.invert_mask identifies the bits to toggle. Bits outside this mask must remain unchanged.flag_masks is a dictionary mapping flag names to nonzero bit masks.inverted_value: the register value after toggling the selected bits.flags: a dictionary mapping each flag name to True if any bit in its mask is set in the original register, otherwise False.The result must be limited to the specified register width. Do not use string conversion or per-bit lists.
def process_register(register_value, width, invert_mask, flag_masks):