Problem Set Solutions/Interrupts & Exceptions/Problem 1


In the instruction sequence above if registers F1, F2, F3, F4, F5, and F6 start out with values 2, 1, -2, 0, 5, and 6, respectively, instruction I5 causes a divide-by-zero exception. Let us assume that such exceptions are detected at the very end of the 6th cycle (out of 8) of DIV execution, and nothing can be done about it until the start of the next cycle.

If the exception handler prints out the values of registers F1, F2, F3, and F4, which values should be printed according to the program order?


According to program order, instructions I1-I4 should be executed before the exception handler is called, and instructions I5-I10 should not be executed yet. The register values should reflect execution of instructions I1-I4, so we have I1: F2=F1*F1 ; F2=4 (2*2)

I2: F4=F4/F2 ; F4=0 (0/4)

I3: F1=F2+F3 ; F1=2 (4+(-2))

I4: F2=F1+F3 ; F2=0 (2+(-2))

After this, we have 2, 0, -2, 0 printed in the exception handler.