[Oberon] Question about SYSTEM.BIT() in Oberon-7

Robert Doiel rsdoiel at gmail.com
Sat Jun 5 19:48:01 CEST 2021


Good morning Jörg (morning in California at least),

The context is really helpful for me. Having missed the original 
Oberon/Oberon Systems boat back when I was a college student I've been 
busy playing catch up. I have struggled with SYSTEM and its appropriate 
application. I am focusing on understanding it better. With regular 
modules is I can go read the source to understand how they work but 
SYSTEM is different. Slowly wrapping my head around that.

I really like your revised DisplayIEEE754 example. SET feels so correct 
and is your version is more readable. I've come to appreciate languages 
that were at least in part designed to be read. I guess that is the 
perhaps one of the important legacies of ALGO.

On to reading Input and Kernel.

All the best,

Robert


On 6/5/21 3:47 AM, Joerg wrote:
> Robert
>
> Of course you can use SYSTEM.BIT the way you used it. However, 
> SYSTEM.BIT is typically used to check HW registers like
> - was a key pressed on the keyboard or
> - did we receive a frame from network or
> - is the bus ready to send data
> - etc
>
> Look at Input.Peek or Kernel.SPI
>
> br
> Jörg
>
>> Am 05.06.2021 um 08:40 schrieb Jörg <joerg.straube at iaeth.ch>:
>>
>>  Robert
>>
>> In Oberon-7 your procedure could look as follows
>>
>> PROCEDURE DisplayIEEE754(x: REAL);
>>   VAR s: SET;
>>   PROCEDURE Bits(str: ARRAY OF CHAR; s: SET; left, right: INTEGER);
>>     BEGIN
>>       Out.String(str);
>>       FOR i := left TO right BY -1 DO
>>         IF i IN s THEN Out.Char(“1“) ELSE Out.Char(“0“) END
>>       END
>>     END Bits;
>>   BEGIN
>>     s := SYSTEM.VAL(SET, x);
>>     Out.String(“sign is “); IF 31 IN s THEN Out.Ch(“-“) ELSE 
>> Out.Ch(“+“) END;
>>     Bits(“, expo (binary): “, s, 30, 23)
>>     Bits(“ frac (binary): “, s, 22, 0);
>>     Out.Ln
>>   END DisplayIEEE754;
>>
>> Gruss, Jörg
>>
>>> Am 05.06.2021 um 01:10 schrieb R. S. Doiel <rsdoiel at gmail.com>:
>>>
>>> 
>>>
>>> That's cool. So what I was thinking of doing is to read the address 
>>> contents of my REAL variable into an INTEGER then use SYSTEM.BIT() 
>>> to report out the sign, the exponent and the fraction. Reading 
>>> Reals.IntL gave that idea.
>>>
>>>
>>>     (** Convert LONGREAL to hexadecimal. h and l are the high and
>>>     low parts. *)
>>>     PROCEDURE IntL* (x: LONGREAL; VAR h, l: LONGINT);
>>>     BEGIN SYSTEM.GET(SYSTEM.ADR(x) + H, h); SYSTEM.GET(SYSTEM.ADR(x)
>>>     + L, l)
>>>     END IntL;
>>>
>>> In the Native Oberon case (Oberon-2) H and L are initialized based 
>>> on system expectation (my interpretation). To better understand the 
>>> SYSTEM module and how it is expected to work I was wondering if this 
>>> made sense in Oberon-7?
>>>
>>>     PROCEDURE DisplayIeee754(x : REAL);
>>>       VAR raw : INTEGER;
>>>     BEGIN
>>>       SYSTEM.GET(SYSTEM.ADR(r), raw);
>>>
>>>       IF SYSTEM.BIT(raw, 31) THEN
>>>         Out.String("sign is -, ");
>>>       ELSE
>>>         Out.String("sign is +, "
>>>       END;
>>>       Out.String(" expo (binary): ");
>>>       FOR i := 31 TO 23 BY -1 DO
>>>         IF SYSTEM.BIT(raw, i) THEN
>>>           Out.Char("1");
>>>         ELSE
>>>           Out.Char("0");
>>>         END;
>>>       END;
>>>       Out.String(" frac (binary): ");
>>>       FOR i := 23 TO 0 BY -1 DO
>>>         IF SYSTEM.BIT(raw, i) THEN
>>>           Out.Char("1");
>>>         ELSE
>>>           Out.Char("0");
>>>         END;
>>>       END;
>>>       Out.Ln;
>>>     END DisplayIeee754;
>>>
>>> Is my understanding correct? If so then I have some compiler 
>>> debugging issues to sort out and that's OK. It's helping me better 
>>> understand language and approach.
>>>
>>> Thanks for the help!
>>>
>>> Robert
>>>
>>> On 6/4/21 3:45 PM, Joerg wrote:
>>>> Robert
>>>>
>>>> You‘re absolutely right:
>>>> SYSTEM.BIT(a, 0) checks the LSB of the word at address a.
>>>>
>>>> I guess for Reals.IntL you don‘t need SYSTEM.BIT.
>>>>
>>>> br
>>>> Jörg
>>>>
>>>>> Am 04.06.2021 um 23:55 schrieb R. S. Doiel<rsdoiel at gmail.com>:
>>>>>
>>>>> 
>>>>> Hello everyone,
>>>>>
>>>>> This is probably a bit of a novice question and I apologize but
>>>>> it has me puzzled.  In the Oberon-7 language report's
>>>>> SYSTEM.BIT() is described as using "n" to address a specific bit.
>>>>> On first reading I assumed "n" zero would be the LSB and "n"
>>>>> thirty one would be MSB where the compiler deals with the local
>>>>> implementation of bit ordering. Is that the correct reading
>>>>> of the report?
>>>>>
>>>>> I was planning on implementing a procedure like Native Oberon's
>>>>> Reals.IntL() but then started having doubts about my reading of the
>>>>> Oberon-7 report. Have I made too simple a set of assumptions about
>>>>> how I should expect SYSTEM.BIT() to work under Oberon-7
>>>>> implementations?
>>>>>
>>>>> All the best,
>>>>>
>>>>> Robert Doiel
>>>>>
>>>>>
>>>>> --
>>>>> Oberon at lists.inf.ethz.ch  mailing list for ETH Oberon and related systems
>>>>> https://lists.inf.ethz.ch/mailman/listinfo/oberon
>>>> --
>>>> Oberon at lists.inf.ethz.ch  mailing list for ETH Oberon and related systems
>>>> https://lists.inf.ethz.ch/mailman/listinfo/oberon
>>> --
>>> Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
>>> https://lists.inf.ethz.ch/mailman/listinfo/oberon
>
> --
> Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
> https://lists.inf.ethz.ch/mailman/listinfo/oberon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.inf.ethz.ch/pipermail/oberon/attachments/20210605/2700678f/attachment.html>


More information about the Oberon mailing list