Sat, 5 November 2016, 19:53
A student writes: > Dr. Patt, > > Before executing an interrupt service routine, we must save copies of > the registers and condition codes so they are not destroyed. However, > I’m having a hard time storing copies of the registers and the > condition codes without taking up a large amount of cycles and states. > Even if the microarchitecture is supplied with specific registers > connected to the BUS to save and restore to (TempR0, TempR1, etc.), it > still takes one cycle for each register (R0 - R5) to store its value > into these registers. This leads to an additional 7 cycles/states to > save (6 cycles to save registers R0 - R5 and 1 cycle for CC) and 7 > cycles to restore from. Am I missing an obvious way to save a copy of > the Reg file in one cycle? I’m nearly out of unused states with these > 14 additional states. > > Thanks, > <<name withheld to protect the student who wants to save all the registers>> Actually, every architect who designs an ISA has to decide what state will be saved on an interrupt or an exception. Most ISAs do in fact save all the general purpose registers. In keeping with my mantra of only including things that are absolutely necessary, the LC-3b saves only the PC and PSR on an interrupt or exception. We save the PC because we need to return to the interrupted program. We save the PSR because we need to save the condition codes PSR[2:0] of the interrupted program. Both are pushed on the stack as part of the initiation microcode before we load PC with the starting address of the service routine. It is important to note that the service routines will have to save/restore any general purpose registers they use so when control is returned to the interrupted program, the registers will contain the values they had when the interrupt or exception was taken. Not a problem since those charged with writing service routines are well aware of the details of the ISA they are working with. Good luck finishing the lab on time. Yale Patt