[Oberon] Alternatives for cases.

Chris Burrows chris at cfbsoftware.com
Sat Mar 9 05:29:52 CET 2019


> -----Original Message-----
> From: Oberon [mailto:oberon-bounces at lists.inf.ethz.ch] On Behalf Of
> Andreas Pirklbauer
> Sent: Friday, 8 March 2019 2:53 AM
> To: ETH Oberon and related systems
> Subject: [Oberon] Alternatives for cases.
> 
>          Data (bytes)    Code (bytes)    Time (ms)
> PROCs     540            1404              65
> IF-ELSE     8             864              53
> CASE        8            1080              42
> 
> Very interesting data!
> 
> 3 questions:
> 
> 1) Has the data for the CASE part been produced
>    with your optimized CASE statement, which uses
>    the "B,cond PC, [Rn]  instruction (where the target
>    of the branch is computed by adding the contents
>    of a register to the current program counter)?
> 

Yes.

> 2) If so, do you have data for a CASE statement that
>    does not use the B, cond PC, [Rn] instruction?
> 
>    (my guess is that it s about 25-50% slower, since in
>    my experimental implementation of the CASE statement,
>    the average overhead of any selection in a CASE
>    statement is 9 instructions - vs 6 in your version
>    with the modified branch instruction)
> 

Time is 44 ms. i.e. about a 5% improvement. I wouldn't expect any more than that because the 50% gain in CASE selection overhead is swamped by the other code that is executing for each selection. i.e. the average gain is n + 9 / n + 6 where n is the average of the total number of instructions executed for each branch.

         Data (bytes)    Code (bytes)    Time (ms)
CASE OLD    8            1072              44

I would expect the new CASE implementation to show more relative improvement for a sparse CASE statement with a large number of 'do nothing' cases. 

> 3) Is there a plan/wish/proposal from your side to make
>    the B, cond PC, [Rn] part of the official RISC spec?
> 

While numeric CASE is not implemented in the official RISC compiler it is not necessary for the instruction to be included in the official RISC spec. If numeric CASE is eventually implemented I would be very surprised if a similar instruction or something even more suitable (e.g. the CASEi instruction of the NS32000 instruction set) did not appear at the same time.

Or, putting it another way, if Wirth decides to extend the RISC instruction set and includes an instruction like CASEi then I would expect to see the CASE statement to appear in the official RISC compiler.

Regards,
Chris

Chris Burrows
CFB Software
http://www.astrobe.com





More information about the Oberon mailing list