<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto">Although TestInt is low-level, it should use Kernel.Install (SYSTEM.ADR(Int), 4) to make it a little bit less low-level😀<br><br>This little wrapper makes interrupts a little bit better consumable:<div>MODULE Interrupts; (* jr/31mar21 *)</div><div>IMPORT S := SYSTEM, Kernel;</div><div>PROCEDURE Install*(handler: PROCEDURE);</div><div>  BEGIN Kernel.Install(S.ADR(handler), 4) END Install;</div><div>PROCEDURE Set*(on: BOOLEAN);</div><div>  BEGIN S.LDPSR(ORD(on)) END Set;</div><div>END Interrupts.</div><div><br></div><div>With it TestInt.Mod gets</div><div>MODULE TestInt;</div><div>IMPORT Interrupts;</div><div>VAR led, cnt: INTEGER;</div><div>PROCEDURE* MyInterrupt;</div><div>  BEGIN</div><div>    INC(cnt); IF cnt = 500 THEN led := 3-led; LED(led); cnt := 0 END</div><div>  END MyInterrupt;</div><div>PROCEDURE On*; BEGIN Interrupts.Set(TRUE) END On;</div><div>PROCEDURE Off*; BEGIN Interrupts.Set(FALSE) END Off;</div><div>BEGIN</div><div>  led := 1; cnt := 0; Interrupts.Install(MyInterrupt)</div><div>END</div><div>TestInt.On</div><div>TestInt.Off</div><div><br></div><div>Interrupts.Mod could be enhanced servicing multiple interrupt handlers. Comparable to the background tasks in Oberon.Mod. This enhancement would install its own interrupt handler doing the scheduling, and the user‘s „interrupt handlers“ are normal procedures without * marking of the procedure. You would then install your handler like this</div><div>PROCEDURE MyTask; BEGIN led := 3 - led; LED(led) END MyTask;</div><div>BEGIN led := 1; Interrupts.Install(MyTask, 500) END TestInt.</div><div><br></div><div><div dir="ltr">br, Jörg</div><div dir="ltr"><br><blockquote type="cite">Am 30.03.2021 um 23:45 schrieb Charles Perkins <chuck@kuracali.com>:<br><br></blockquote></div><blockquote type="cite"><div dir="ltr"><div dir="ltr"><div>Hello Everybody,</div><div><br></div>I wanted to explore interrupt handling in Oberon and I discovered that Peter De Wachter's excellent emulator did not implement them, which is not surprising, as the current Project Oberon source doesn't use them as far as I can tell and the only example source code showing how to use interrupts is the TestInt module on Professor Wirth's own 2018 update to RISC5: <a href="https://people.inf.ethz.ch/wirth/ProjectOberon/RISC5.Update.pdf">https://people.inf.ethz.ch/wirth/ProjectOberon/RISC5.Update.pdf</a><div><br></div><div>Since I wanted to compile and run that small example I forked Peter's emulator and added support for Interrupts in a branch here: <a href="https://github.com/io-core/oberon-risc-emu">https://github.com/io-core/oberon-risc-emu</a> (only a few small changes were needed.)</div><div><br></div><div>With those changes I am able to compile the TestInt module and execute it in the emulator using the 2019 disk image in the repo. Emulated LEDs update once per second as expected.</div><div><br></div><div>I don't intend to maintain a fork of Peter's emulator, I just wanted to experiment with interrupts and share the implementation in case anyone else is interested.</div><div><br></div><div>Best Regards,</div><div>Chuck</div></div>
<span>--</span><br><span>Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems</span><br><span>https://lists.inf.ethz.ch/mailman/listinfo/oberon</span><br></div></blockquote></div></body></html>