[Oberon] Riders / Auto-Increment (was:Negative integer literals in Oberon)
chris at cfbsoftware.com
Wed Apr 29 00:26:06 CEST 2020
It is true that the RIDER feature was not included in the design of the language Oberon-07. However, it is not relevant that the RISC5 CPU does not offer an auto-increment feature. Unless I have misunderstood you I interpret the statement:
“This is not existing in Oberon-07 as the RISC5 CPU does not offer the autoincrement feature.”
as somehow implying that the design of the Oberon language is dependent on the features of the RISC5 instruction set. If so that could not be further from the truth. It would be quite possible to implement the RIDER feature on any CPU which was otherwise suitable as an Oberon target system regardless of whether or not the instruction set had an auto-increment feature.
The reason that the RIDER feature was abandoned in Oberon-07 is explained in the document ‘An Oberon Compiler for the ARM Processor’. Niklaus Wirth 18.12.2007, rev. 16.4.2008.
The third facility of array riders had been implemented on an earlier version of the Oberon-SA compiler, and it resulted in significant speedup for sequential access with arrays. However, we recognized that this situation occurs relatively rarely, whereas the compiler was made more complex for good. Consequently, we decided to drop that feature and will not further discuss it here.
You can download a copy of this document from:
inf.ethz.ch <https://inf.ethz.ch/personal/wirth/Oberon/Oberon.ARM.Compiler.pdf> › personal › wirth › Oberon.ARM.Compiler.pdf
However, the auto-increment feature does exist in various ARM instruction sets. In the Astrobe compilers we came up with a much simpler way than the RIDER concept to utilise its potential for efficiency. Since release v4.5 of Astrobe in 2013 we have included an optional third parameter on the SYSTEM.GET and SYSTEM.PUT functions. This is described in the documentation as follows:
An optional integer constant parameter inc can be used with GET and PUT to automatically increment / decrement the value of address. If inc is in the range 1..255 the address is incremented after the value is stored. If inc is in the range -1..-255 the address is decremented before the value is stored. Typical values for inc are 1 for byte accesses and 4 for word accesses.
Code examples and a discussion of the performance gains (e.g. five times faster) can be seen in the topic Fast ARRAY and RECORD moves in the Astrobe forum:
https://www.astrobe.com/forum/viewtopic.php?f=10 <https://www.astrobe.com/forum/viewtopic.php?f=10&t=404> &t=404
For those who have a desire to get some real hands-on experience with modifying the Project Oberon compiler and / or understanding Verilog and how to maintain / port / extend the RISC5 processor an excellent starting exercise would be to implement this extended form of SYSTEM.GET and SYSTEM.PUT in the Project Oberon RISC5 compiler by:
a) Using the standard RISC5 instruction set
b) Using an extended RISC5 instruction set that includes an auto-increment feature
Ideally b) would include updated Verilog sources and be demonstratable on real hardware, but for those not fortunate enough to have the hardware to do this, the next best thing would be to modify one of the existing RISC5 emulators.
If sufficient interest is shown I’ll consider running a competition with a prize for the best (in my opinion) solution. Keep a watch on the Astrobe forum for details.
From: Oberon [mailto:oberon-bounces at lists.inf.ethz.ch] On Behalf Of Jörg
Sent: Wednesday, 29 April 2020 1:31 AM
To: ETH Oberon and related systems
Subject: Re: [Oberon] Negative integer literals in Oberon
One of the new features in Oberon-SA was the base type RIDER, a special case of POINTER TO ARRAY
RIDERs are useful, if the CPU offers special pre/post increment/decrement.
In e.g. Oberon-07 you write something like
VAR s, x, y: REAL; ra, rb, limit: POINTER TO REAL;
s := 0.0; ra := SYSTEM.ADR(a); rb:= SYSTEM.ADR(b); limit := ra + n*4;
WHILE ra < limit DO
SYSTEM.GET(ra, x); SYSTEM.GET(rb, y);
s := x * y + s; INC(ra, 4) INC(rb, 4)
With RIDERS it looks like this:
VAR s: REAL; ra, rb, limit: RIDER REAL;
s := 0.0; SET(ra, a, 0); SET(rb, b, 0); SET(limit, a, n);
WHILE ra < limit DO s := ra^ * rb^ + s END;
This is not existing in Oberon-07 as the RISC5 CPU does not offer the autoincrement feature.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Oberon