<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto">John<div><br></div><div>there is indeed an error in chapter 9.5 of the pdf you linked.</div><div><br></div><div>If you read bullet 3 in the intro to chapter 9.5 a distinction of adr>= 0 and adr<0 is mentioned for the memory mapped IO. But as mentioned in the intro, memory mapped IO is not implemented. For a fully working emulator you will need this IF adr>=0 and IF adr<0.</div><div>But for this reduced mini emulator code in chapter 9.5, this IF is wrong (most probably a leftover of the full code). Take the sample code Chris provided.</div><div><br><div dir="ltr">br<br><div>Jörg</div></div><div dir="ltr"><br><blockquote type="cite">Am 27.03.2022 um 14:11 schrieb Chris Burrows <cfbsoftware@gmail.com>:<br><br></blockquote></div><blockquote type="cite"><div dir="ltr"><div dir="ltr"><div dir="ltr">On Sun, Mar 27, 2022 at 9:38 PM John Stout <<a href="mailto:cuspcomputers@gmail.com">cuspcomputers@gmail.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Hello everyone</div><div dir="ltr"><br></div><div dir="ltr">I'm working on a compiler and emulation of the RISC processor detailed in the latest (?) edition of Compiler Construction by Professor Wirth from <a href="http://www.projectoberon.net/wirth/CompilerConstruction/CompilerConstruction.pdf" target="_blank">CompilerConstruction1.pdf (projectoberon.net)</a>.</div><div dir="ltr"><br></div><div dir="ltr">I can't follow the Oberon code for the emulator in section 9.5 in the section handling memory instructions, which differs from Peter De Wachter's Oberon RISC emulator at <a href="https://github.com/pdewacht/oberon-risc-emu.git" target="_blank">https://github.com/pdewacht/oberon-risc-emu.git</a> </div><div dir="ltr"><br></div><div>In Compiler Construction, once an instruction has been decoded as a memory instruction the address is calculated using</div><div><br></div><div><font face="monospace">adr := (R[b] + IR MOD 100000H) DIV 4;</font></div><div><br></div><div dir="ltr">which (apart from the DIV 4) agrees with the code in <font face="monospace">oberon-risc-emu</font> (which also sign extends the offset before adding it).</div><div dir="ltr"><br></div><div dir="ltr">If <font face="monospace">adr >= 0</font><font face="arial, sans-serif"> then a load is carried out, and the N and Z flags set depending on the value loaded.</font></div><div dir="ltr"><font face="arial, sans-serif">However (and this is the bit I don't understand) if </font><font face="monospace">adr < 0</font><font face="arial, sans-serif"> then a store is carried out, whereas in oberon-risc-emu u bit of the instruction is checked and if 0 a load is carried out and if 1 a store is carried out.</font></div><div dir="ltr"><font face="arial, sans-serif"><br></font></div><div dir="ltr"><font face="arial, sans-serif">Since I know </font><font face="monospace">oberon-risc-emu</font><font face="arial, sans-serif"> works, and that agrees with the settings for the u and v bits in Compiler Construction then I assume that must be the correct implementation, but is there an error in Compiler Construction or am I missing something very simple?</font></div><div dir="ltr"><font face="arial, sans-serif"><br clear="all"></font><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>All the best.</div><div><br></div><div>John Stout</div></div></div></div></div></div></div></div></div></div></div></div></div></blockquote><div><br></div><div>Have a closer look. In Compiler Construction the test for load / store is NOT based on the sign of adr, it is based on one of the following equivalent tests:</div><div><br></div><div>IF ~ODD(IR DIV 20000000H) (* in the book *)<br></div><div><br></div><div>or</div><div><br></div><div>IF ~ODD(ASH(IR, -29)) (* in the accompanying source code *)<br></div><div><br></div><div>--</div><div>Regards,</div><div>Chris Burrows</div><div>CFB Software</div><div><a href="https://www.astrobe.com/RISC5">https://www.astrobe.com/RISC5</a></div><div><br></div></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>