Re: [Oberon] Stimulus driven interrupts?
Thank you Jörg - this clears a lot up In the paper from N Wirth that I linked ( http://norayr.am/papers/WirthTasksVersusThreads.pdf), he mentions an "interrupt vector" (page 10). Does this mean that multiple interrupts can be setup in a priority order? much obliged, Jeff 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) normal proc: interrupt proc: SUB SP SP localsize SUB SP SP localsize 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
participants (1)
-
Jeff Maggio