[Oberon] Easter eggs in Oberon

Joerg joerg.straube at iaeth.ch
Mon Apr 13 18:40:44 CEST 2020


Wojtek

Indeed, universal bit patterns can not be manipulated as elegantly as in e.g. Verilog.
But in most cases the SET abstraction provided in Oberon-07 is enough, not optimal but enough.

For low level programming Oberon-07 offers even a BIT procedure like here:
REPEAT UNTIL SYSTEM.BIT(spiCtrl, 5)
wait until bit 5 at IO address spiCtrl is set.

In Oberon-07, the author of a low level program is free to define either INTEGER constants or SET constants. An imaginary example:

fast = 01H;
word = 02H;
chipSelect = 04H;
interrupt = 08H;
SYSTEM.PUT(spiCtrl, fast+ interrupt);

is equivalent to:

fast = {0};
word = {1};
chipSelect = {2};
interrupt = {3};
SYSTEM.PUT(spiCtrl, fast + interrupt);

br
Jörg

> Am 13.04.2020 um 18:02 schrieb Skulski, Wojciech <skulski at pas.rochester.edu>:
> 
> Joerg:
> 
> we are still struggling with the distinction between an integer number and a bit pattern. The internal representation of an integer number should be immaterial as long as it implements math. The internal representation of the bit pattern is paramount because its main goal is transmission, hardware control, and turning bits on/off. The bit patterns need not implement math. Using math operators to manipulate bits is pervert. 
> 
> It would be better / cleaner if bits patterns were used for bit manipulations, and integers were for math and for enumerations. 
> 
> Wojtek
> ________________________________________
> From: Oberon [oberon-bounces at lists.inf.ethz.ch] on behalf of Joerg [joerg.straube at iaeth.ch]
> Sent: Monday, April 13, 2020 11:36 AM
> To: ETH Oberon and related systems
> Subject: Re: [Oberon] Easter eggs in Oberon
> 
> August
> 
> The word „numeric type“ is not clearly defined in the report.
> 
> Eg. is BYTE part of the numeric types?
> Or is INTEGER part of the numeric type?
> If it was you sould be able to write i := i / 3;  (as / is defined on numeric types)...
> 
> The Oberon report leaves some room for interpretation... (especially for corner cases)
> 
> b := -2;  is equivalent to b := 254;
> 
> br
> Jörg
> 
>>> Am 13.04.2020 um 15:16 schrieb August Karlstrom <fusionfile at gmail.com>:
>>> 
>>> On 2020-04-12 13:00, Joerg wrote:
>>> There is no „byte multiplication“;
>> 
>> The language report says that
>> 
>> "The operators +, −, *, and / apply to operands of numeric types. Both operands must be of the same type, which is also the type of the result."
>> 
>> If both operands have type BYTE then multiplication is BYTE multiplication as far as the language is concerned. It will probably be implemented using 32-bit or 64-bit multiplication but that's an implementation detail.
>> 
>>> the type BYTE modifies the assignment not the multiplication;
>>> After these statements
>>>    b := -2;
>> 
>> In the language report BYTE is defined as "the integers between 0 and 255" and "The type BYTE is compatible with the type INTEGER, and vice-versa." This implies that INTEGER is compatible with BYTE *only* if the value is between 0 and 255. Therefor the above statement is invalid.
>> 
>>>    b := b * 256;
>> 
>> Here, b on the right hand side is interpreted as an INTEGER and the type of the product is INTEGER. The result is then interpreted as a BYTE and assigned to b. The statement above is well defined only when b = 0.
>> 
>>> b is 0 although the multiplication results in 65024. Can be verified by these statements >      b := -2;
>>>    i := b * 256;
>> When the result is undefined you can potentially get anything.
>> 
>> 
>> -- August
>> --
>> Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
>> https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.inf.ethz.ch_mailman_listinfo_oberon&d=DwIGaQ&c=kbmfwr1Yojg42sGEpaQh5ofMHBeTl9EI2eaqQZhHbOU&r=uUiA_zLpwaGJIlq-_BM9w1wVOuyqPwHi3XzJRa-ybV0&m=CSM6Iv2aRXld9AFZg2XQ5W-OBBW6gXkzZb6Cjr13vjs&s=cgxJFXM0OE4FvZQLWFklqaHs6OTe4xHuIkiMi92VoAc&e=
> 
> --
> Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
> https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.inf.ethz.ch_mailman_listinfo_oberon&d=DwIGaQ&c=kbmfwr1Yojg42sGEpaQh5ofMHBeTl9EI2eaqQZhHbOU&r=uUiA_zLpwaGJIlq-_BM9w1wVOuyqPwHi3XzJRa-ybV0&m=CSM6Iv2aRXld9AFZg2XQ5W-OBBW6gXkzZb6Cjr13vjs&s=cgxJFXM0OE4FvZQLWFklqaHs6OTe4xHuIkiMi92VoAc&e=
> --
> 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