Use a scratch register in the semaphore functions