[Oberon] Bit manipulation in Oberon-07
Jörg
joerg.straube at iaeth.ch
Thu Oct 25 07:22:52 CEST 2018
Hi
SET is neglected indeed. But SETs and INTEGERs are two different things.
ORD seems handy but the whole topic of endianness makes your ORD() code not portable. So use it with care.
The Oberon spec does not state whether the statement s := {0}; sets LSB or MSB. In other words it's not specified whether
ORD( {0} ) = 1 or ORD( {0} ) = 80000000H
This is left to the compiler implementor.
Better is to use SYSTEM.VAL(INTEGER, s) or SYSTEM.VAL(SET, i). By importing SYSTEM you flag your code as "not portable“.
When porting code from one processor to another you immediately know, you most probably have to adapt the code to cope with a) underlying endianness, b) compiler differences or c) word width.
br
Jörg
> Am 25.10.2018 um 06:44 schrieb Skulski, Wojciech <skulski at pas.rochester.edu>:
>
> Joerg:
>
>> Normally you are right: bit manipulation is easiest with SET, eg my color display driver is full of SET manipulations.
>
> Inspired by Chris, I looked up NW papers and I found some SET advocacy there:
>
> www.inf.ethz.ch/personal/wirth/Oberon/index.html --> SET: A neglected data type and its compilation for the ARM
>
> Unfortunately, the conversion between the SET and INTEGER is not covered in that note. The discussion of SYSTEM.VAL versus nonexistent BITS is still not resolved in that paper.
>
> 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