[Oberon] Bit manipulation in Oberon-07

Jörg Straube joerg.straube at iaeth.ch
Sat Oct 27 19:53:41 CEST 2018


Wojtek, Chris

I fully understand that in a Cortex-M compiler there might be the need to allow low level access to single assembler instructions of that specific CPU.

So a procedure SYSTEM.UBFX makes sense as the compiler maps it to the corresponding Cortex-M CPU instruction.

(I thought UBFX would need least significant bit number and width. So UBFX(7,3) should extract bit 7,8 and 9) and not bit 3..7

However, I don‘t like the idea to make this procedure available in a RISC5 compiler. In my point of view this goes to far abd can be seen as kind of misuse of SYSTEM to emulate CPU instructions of one CPU (Cortex M) on another CPU (RISC5).

Luckily in this case the bit numbering of Cortex M and the bit numbering of RISC5 are identical, both use LSB0. But if one CPU used MSB0 and the other LSB0, what is the definition of the UBFX arguments then?

UBFX(7,3) can be written as „DIV 128 MOD 8“

Jörg

> Am 27.10.2018 um 05:51 schrieb Skulski, Wojciech <skulski at pas.rochester.edu>:
> 
> Chris:
> 
>> We have implemented two SYSTEM functions in the Astrobe for ARM Cortex-M
>> compilers which use the ARM bitfield instructions BFI (Bitfield insert) and
>> UBFX (Unsigned bitfield extract). These are very convenient to use when
>> accessing arbitrary groups of bits that represent a positive integer buried
>> in the middle of a 32-bit word. Here are some examples:
> 
> This is wonderful. I hope that Oberon System compiler implementers  are listening!
> 
> Thank you for the example functions (snipped in this response). The students will appreciate your efficient way of coding.
> 
> Thank you,
> 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