[Oberon] Hennessy.Mod 64kB limit

Joerg joerg.straube at iaeth.ch
Tue Feb 18 16:54:04 CET 2020


Wojtek

I agree, looking at low level source code is not a beginner's starting point :-)
Bit manipulations are not obvious; it does not get better if you use >> or ASR() or similar. To read the code you need a basic understanding of what the bits mean you want to extract. The lines below will get obvious if you deep dive into the RISC5 assembler code.

inst = holds the instruction
mno = module name
pno = procedure name
disp = displacement, offset

But this is not the "normal" way of Oberon programming. It is really dedicated to low level programming to implement system routines, linker, compiler and other really geeky stuff...
"MOD 10H" extracts a nibble, in C you might write "& 15"
"MOD 100H" extracts a byte, in C you might write "& 255"
To understand "0F7000000H" you have to look at this document https://inf.ethz.ch/personal/wirth/FPGA-relatedWork/RISC-Arch.pdf
After you got familiar to it, you will see: F7 is a branch instruction and the lower 24 bits are the offset

br
Jörg

-----Original Message-----
From: Oberon <oberon-bounces at lists.inf.ethz.ch> On Behalf Of Skulski, Wojciech
Sent: Tuesday, February 18, 2020 4:28 PM
To: ETH Oberon and related systems <oberon at lists.inf.ethz.ch>
Subject: Re: [Oberon] Hennessy.Mod 64kB limit

Joerg:

it is a Law Of Nature that "one person's constant is another person's variable". A constant will be modified sooner or later. It is not a question "if", but rather "when". 

So I would add another rule to your two:

3) If the constant has a system ramification (such as code size, stack size, etc.) it should be factored out to the CONST section even if it is used only once.

Another vicious example is "bit constants" which are scattered all over Oberon System, combined with a habit of using MOD and DIV for bit manipulation. Originally the MOD and DIV operators were defined for integer math. Then someone noticed these can also manipulate individual bits, if used with bit masks. Per ETH habits, these bit masks are then coded in hex and proudly left in the code in dozens of places. The net result was creation of "code idioms" whose meaning is stretching the meaning integer math operators. A particular example looks like this, taken from the actual Oberon System code. It is breaking all rules of human-to-human communication. Also note that per ETH rules such idioms are left uncommented.

  mno := inst DIV 100000H MOD 10H;
  pno := inst DIV 1000H MOD 100H;
  disp := inst MOD 1000H;
          ....
  SYSTEM.PUT(adr, (offset MOD 1000000H) + 0F7000000H);

 I qualify such code as "in order to confuse the enemy" programming style. 

The bottom line: If the community spent thirty years developing a very powerful abstract language where hacks are supposedly not necessary, then the community should avoid hacks. Especially after writing so many books and articles on the merits of good programming. What I have shown above should not be allowed. If it has become a habit then something is badly missing in the language. Either the Gospel is not really the Gospel, or the language is missing some crucial features which are then emulated with pieces of nasty code.


Wojtek
________________________________________
From: Oberon [oberon-bounces at lists.inf.ethz.ch] on behalf of Joerg [joerg.straube at iaeth.ch]
Sent: Tuesday, February 18, 2020 10:00 AM
To: 'ETH Oberon and related systems'
Subject: Re: [Oberon] Hennessy.Mod  64kB limit

Wojtek

You are right CONST are a good thing.
Personally, I change from literals to CONST if two conditions are met:
a) I use the value more than once
b) I intend to change it
As said, this is my personal agreement. In our current case both conditions are not met 😊

Eg if you look at my Display.color.Mod I heavily use CONSTs in contrast to the current Display.Mod that is full of literals that might change if you have another resolution.

br
Jörg


-----Original Message-----
From: Oberon <oberon-bounces at lists.inf.ethz.ch> On Behalf Of Skulski, Wojciech
Sent: Tuesday, February 18, 2020 3:46 PM
To: ETH Oberon and related systems <oberon at lists.inf.ethz.ch>
Subject: Re: [Oberon] Hennessy.Mod 64kB limit

Joerg wrote:

>The 64KB limit is known, but I'm surprised as well that this limit is not checked.
> Add to ORG.CheckRegs the following IF:
>   IF varsize + strx > 0FFFFH THEN ORS.Mark("too many globals") END;

This amounts to a sin. Hardcoded literals are against Niklaus Wirth school of programming. I have picked relevant citations from The Gospel. Why is the community disregarding The Gospel?

This should be:
CONST GLOBLIMIT = 0FFFFH;  (*or GlobLimit, MaxVar, or any good and descriptive name*)

IF varsize + strx > GLOBLIMIT THEN ORS.Mark("too many globals") END;

Shall we ever learn from Niklaus Wirth?

Thanks,
Wojtek
--
Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://lists.inf.ethz.ch/mailman/listinfo/oberon



More information about the Oberon mailing list