program to simulate a register