Since the interrupt mask register is write-only, its value cannot be read. Therefore, the value written to the interrupt mask register is held in the library. Specifically, the method is as follows.
(1) Prepare a memory that always has the same contents as the interrupt mask register (hereinafter referred to as mask storage memory)
(2) When writing to the interrupt mask register, always write the same contents to the mask save memory.
(3) When reading the interrupt mask register, read the contents of the mask save memory.