[Oberon] Compiler Construction on projectoberon.net

Joerg joerg.straube at iaeth.ch
Sun Mar 27 14:48:04 CEST 2022


John

there is indeed an error in chapter 9.5 of the pdf you linked.

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.
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.

br
Jörg

> Am 27.03.2022 um 14:11 schrieb Chris Burrows <cfbsoftware at gmail.com>:
> 
> 
>> On Sun, Mar 27, 2022 at 9:38 PM John Stout <cuspcomputers at gmail.com> wrote:
> 
>> Hello everyone
>> 
>> I'm working on a compiler and emulation of the RISC processor detailed in the latest (?) edition of Compiler Construction by Professor Wirth from CompilerConstruction1.pdf (projectoberon.net).
>> 
>> 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 https://github.com/pdewacht/oberon-risc-emu.git 
>> 
>> In Compiler Construction, once an instruction has been decoded as a memory instruction the address is calculated using
>> 
>> adr := (R[b] + IR MOD 100000H) DIV 4;
>> 
>> which (apart from the DIV 4) agrees with the code in oberon-risc-emu (which also sign extends the offset before adding it).
>> 
>> If adr >= 0 then a load is carried out, and the N and Z flags set depending on the value loaded.
>> However (and this is the bit I don't understand) if adr < 0 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.
>> 
>> Since I know oberon-risc-emu 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?
>> 
>> All the best.
>> 
>> John Stout
> 
> 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:
> 
> IF ~ODD(IR DIV 20000000H)  (* in the book *)
> 
> or
> 
> IF ~ODD(ASH(IR, -29)) (* in the accompanying source code *)
> 
> --
> Regards,
> Chris Burrows
> CFB Software
> https://www.astrobe.com/RISC5
> 
> --
> Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
> https://lists.inf.ethz.ch/mailman/listinfo/oberon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.inf.ethz.ch/pipermail/oberon/attachments/20220327/490d6eb8/attachment.html>


More information about the Oberon mailing list