<div dir="ltr"><span style="color:rgb(0,0,0);font-family:Verdana,Arial,Helvetica,sans-serif;font-size:13.3333px">Thank you Jörg - this clears a lot up</span><br style="color:rgb(0,0,0);font-family:Verdana,Arial,Helvetica,sans-serif;font-size:13.3333px"><br style="color:rgb(0,0,0);font-family:Verdana,Arial,Helvetica,sans-serif;font-size:13.3333px"><br style="color:rgb(0,0,0);font-family:Verdana,Arial,Helvetica,sans-serif;font-size:13.3333px"><span style="color:rgb(0,0,0);font-family:Verdana,Arial,Helvetica,sans-serif;font-size:13.3333px">In the paper from N Wirth that I linked (</span><a target="_blank" href="http://norayr.am/papers/WirthTasksVersusThreads.pdf" style="color:rgb(89,143,222);font-family:Verdana,Arial,Helvetica,sans-serif;font-size:13.3333px">http://norayr.am/papers/WirthTasksVersusThreads.pdf</a><span style="color:rgb(0,0,0);font-family:Verdana,Arial,Helvetica,sans-serif;font-size:13.3333px">), he mentions an "interrupt vector" (page 10). Does this mean that multiple interrupts can be setup in a priority order?</span><br style="color:rgb(0,0,0);font-family:Verdana,Arial,Helvetica,sans-serif;font-size:13.3333px"><br style="color:rgb(0,0,0);font-family:Verdana,Arial,Helvetica,sans-serif;font-size:13.3333px"><span style="color:rgb(0,0,0);font-family:Verdana,Arial,Helvetica,sans-serif;font-size:13.3333px">much obliged,</span><br style="color:rgb(0,0,0);font-family:Verdana,Arial,Helvetica,sans-serif;font-size:13.3333px"><span style="color:rgb(0,0,0);font-family:Verdana,Arial,Helvetica,sans-serif;font-size:13.3333px">Jeff </span><br style="color:rgb(0,0,0);font-family:Verdana,Arial,Helvetica,sans-serif;font-size:13.3333px"><div><span style="color:rgb(0,0,0);font-family:Verdana,Arial,Helvetica,sans-serif;font-size:13.3333px"><br></span></div><div><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">In addition to Chris’ reply. Here a minimum implementation of Install*(handler: PROCEDURE);
SYSTEM.LDPSR(0); (* disable/clear interrupt *)
Kernel.Install(SYSTEM.VAL(INTEGER, handler), 4); (* install the interrupt handler at memory address 4 *)
SYSTEM.LDPSR(1); (* enable/set interrupt *)
LDPSR is the abbreviation for “load processor status register”. The last bit of this status register is “interrupt: on/off”
As interrupts begin and end differently than “normal” procedures, and it has bad consequences if you install a “normal” procedure as interrupt handler, I decided to check that the parameter “handler” is really an interrupt procedure. To do this I check the procedure’s prolog. Here the start of the prolog (=the code the compiler generates when it sees a BEGIN)<br> normal proc: interrupt proc:<br> SUB SP SP localsize SUB SP SP localsize<br> STW LNK SP 0 STW R0 SP 0
…. …
The first instruction is the same but the second instruction differs.
SYSTEM.LDPSR(0); (* disable/clear interrupt *)
Kernel.Install(SYSTEM.ADR(Empty), 4); (* see below *)
SYSTEM.GET(SYSTEM.VAL(INTEGER, handler)+4, instr); (* get second instruction of the “handler” code. If “handler” is NIL the check below is never true *)
IF instr = 0A0E00000H THEN (* valid interrupt handler *) (* check for STW R0 SP 0 *)
Kernel.Install(SYSTEM.VAL(INTEGER, handler), 4); (* install interrupt handler at memory address 4 *)
SYSTEM.LDPSR(1) (* enable/set interrupt *)
END
The “Empty” interrupt is a precaution in case the programmer’s interrupt handler is not valid or NIL and the programmer would code a SYSTEM.LDPSR(1) on his own after Install(). I could put this code in the ELSE.
Instead of SYSTEM.GET(SYSTEM.VAL(INTEGER, handler)+4, instr); the compiler would also accept the shorter SYSTEM.GET(ORD(handler)+4, instr);
As the Oberon report does not define ORD() on procedure variables, I use the “official” way of doing it.
br
Jörg</blockquote><br class="gmail-Apple-interchange-newline"></div></div>