Re: [Oberon] Compiler Construction PDF error
Ah, I didn't think to look at the source code on the site which would have been the last word. Many thanks. All the best. John On Mon, 28 Mar 2022 at 11:00, <oberon-request@lists.inf.ethz.ch> wrote:
Send Oberon mailing list submissions to oberon@lists.inf.ethz.ch
To subscribe or unsubscribe via the World Wide Web, visit https://lists.inf.ethz.ch/mailman/listinfo/oberon or, via email, send a message with subject or body 'help' to oberon-request@lists.inf.ethz.ch
You can reach the person managing the list at oberon-owner@lists.inf.ethz.ch
When replying, please edit your Subject line so it is more specific than "Re: Contents of Oberon digest..."
Today's Topics:
1. Compiler Construction on projectoberon.net (John Stout) 2. Re: Compiler Construction on projectoberon.net (Chris Burrows) 3. Re: Compiler Construction on projectoberon.net (Joerg) 4. Re: Compiler Construction on projectoberon.net (Chris Burrows)
----------------------------------------------------------------------
Message: 1 Date: Sun, 27 Mar 2022 11:07:43 +0000 From: John Stout <cuspcomputers@gmail.com> To: oberon@lists.inf.ethz.ch Subject: [Oberon] Compiler Construction on projectoberon.net Message-ID: < CAE7M_X1Z_QJpjVft+pGexpLpaq7FggUYgJNA4YfWtv4zHwLanA@mail.gmail.com> Content-Type: text/plain; charset="utf-8"
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) < http://www.projectoberon.net/wirth/CompilerConstruction/CompilerConstruction...
.
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
participants (1)
-
John Stout