ST R1,0(R4) ; This instruction may occasionally fault. IF FAULT ST R4,EX ; If so do this. BAL R14,FIX ENDIFIF and ENDIF are assembler macros. In particular “IF FAULT” compiles no instructions but forms a new entry in a table consulted by the code that runs upon a mapping fault. This table had just a few entries for the 370 Keykos kernel. A table entry was a pair of instruction addresses:
Such faults were rare and the normal case paid neither execution time or cache space to hold the exception code, or even the address of the exception code. The same pattern works for divide by zero but our kernel did not need that.
I see no reason why compilers cannot use just this pattern. A small negotiation with the run-time is necessary.
This pattern was not limited to privileged code, but was most used there.
More common variations on IF included “IF Z” often coded following an instruction that set the condition code. A conditional branch would then be produced to the out-of-line code. We considered but did not implement variations on the IF forms that compiled conditional branches. The variation would specify that the condition was likely true and then the nested code would be compiled in-line for better performance. There were few if any conditional branches in the 370 kernel that were likely. That is not true of other code that I have written. That it is true of the kernel warrants a philosophical note that I have not written.