Cleanup of panic register spill code.
A basic primitive for save update of a counting semaphore.