Tue, 3 Dec 2013, 22:23

My students,

A student asks about interrupt vector tables, which gives me an opportunity
to reinforce the notion with the rest of you.  I will not tell him exactly
what to do, but I will (hopefully) provide some insights.

A student writes:

> Dear Dr. Patt,
> I have been reading through the material and overlooking my notes and
> I still cannot make sense of the interrupt vector table. This is in
> regards to the second part of the operating system enabling code: "2.
> Also, normally, the operating system establishes the interrupt vector
> table to contain the starting addresses of the corresponding interrupt
> service routines. You will have to do that for the keyboard interrupt.
> The starting address of the interrupt vector table is x0100 and the
> interrupt vector for the keyboard is x80. It is necessary for you to
> only provide the one entry in the interrupt vector table that is
> needed for this programming lab assignment."
> I don't understand what exactly it is I'm supposed to do? Do I load
> the interrupt vector x80 into location x0100, or am I loading
> something else into location x0180?
> Any advice is appreciated.
> Thank you in advance,
> <<name withheld to protect the student who asks what he is supposed to do>>

A few comments in my attempt to be helpful:

Comment 1: The interrupt vector table is like the trap vector table.  It
contains the starting address of every interrupt service routine.  Recall 
that the trap vector table uses locations x0000 to x00FF, and the trapvector
tells you which entry in the table contains the starting address of the
corresponding trap service routine.  The interrupt vector table uses 
memory locations x0100 to x01FF, and the accompany interrupt vector tells you
which entry in the table contains the starting address of the corresponding
interrupt service routine.

Comment 2: The difference between the two is that trap service routines 
are called directly by the program, whereas interrupt service routines 
are caused by events happening that have nothing to do with the program
that is running.  Someone hitting a key on the keyboard, for example.  
The TRAP instruction is the mechanism in the program to call the trap service 
routine, and in particular to make sure that the operating system executes 
the correct service routine.  To make sure the correct interrupt service
routine is executed in the case of an interrupt, every external event comes
with an interrupt vector which is used to index into the interrupt vector
table to get the correct starting address.  

Hope the above helps and you can now see what the operating system must do
before anyone hits a key on the keyboard.  The only reason you are doing it
at the start of your user program is that I have been unsuccessful at getting
Microsoft to fix Windows so it can run on the LC-3.  [By the way, the jargon
for saying "fix Windows so it can run on the LC-3" is "Port Windows to the 
LC-3."  ...and I hasten to add: I will not expect you to know this term "port"
on the final exam.]

Good luck finishing the last program this week.

Yale Patt