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

R. S. Doiel rsdoiel at gmail.com
Sat Jun 5 01:09:14 CEST 2021


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.inf.ethz.ch/pipermail/oberon/attachments/20210604/2a11c51f/attachment.html>


More information about the Oberon mailing list