A certain processor provides a 'test and set' instruction that is used as follows:
TSET register, flag
This instruction atomically copies flag to register and sets flag to $1$. Give pseudo-code for implementing the entry and exit code to a critical region using this instruction.