Homework 8 on Writing Your Own Exception/Interrupt Handler
Andrew Sohn, Computer Science Department, New Jersey Institute of Technology
Write an "Assembly handler" and a correspodning "C handler."
Try to follow the steps below and also the ones discussed in class yesterday:
Obtain the IDT table address using inline assembly. See store_idt()/load_idt() for loading and storing the IDT base address.
Replace the high and low address of IDT entry
n
with the new high/low address, where
n
is an exception number.
The new high and low address that would go into the IDT entry will be defined by your own assembly handler.
Write your own assembly handler. Use this handler address as the new high & low in IDT.
Your assembly handler will call your own C handler.
Your C handler will print or do something to indicate that your C handler is activated.
Your C handler will terminate normally and return to your assembly handler.
Upon returning from your C handler, your assembly handler will jump to the
original
asm handler.
Find the original C handler address from System.map.
The following statments in your application will generate a "divide error" exception with the message "Floating point exception."
int i=1, j=0; printf("%d",i/j);
Make sure to include some print statements to indicate that the handler is activated.
Include your name and the nature of the exception/interrupt along with the condition(s) that triggered the event if possible.
The above example is one of many possibilities. Check the web for more references and try several different techniques if your time allows.