Write code to set, clear, and toggle specific bits in a hardware control register without affecting adjacent bits.