[Oberon] Bit manipulation in Oberon-07
chris at cfbsoftware.com
Tue Oct 30 05:49:36 CET 2018
> On 29 Oct 2018, at 9:32 am, Jörg Straube <joerg.straube at iaeth.ch> wrote:
> inline procedures or macros are not part of the Oberon-7 language. Some previous Oberon dialects had them...
Inline procedures do not necessarily require a language change. It would be feasible for an implementation of an Oberon-07 compiler to automatically inline any procedure smaller than a (user-defined?) threshold value e.g. less than five generated instructions. There may also be other constraints to be considered.
> SYSTEM procedures can be seen as kind of inline procedures as they look like procedure calls but are infact in a lot of cases just a wrapper to one assembler instruction.
The main reason for suggesting that UBFX and BFI be implemented as SYSTEM procedures is so that they would be inlined and more efficient. Automatic inlining would remove that need.
> I agree that for Oberon beginners MOD and DIV look quite cryptic and difficult to understand. MOD/DIV are just other words for AND/ASR...
Not just beginners. It always felt like an uncomfortable kludgey workaround to me to have to use operators specifically named to represent integer division and modulus for operations that, in reality, were bit shifts and masks. E.g. packing / unpacking variant bit fields and words. I would be equally perplexed if I was told that when I wanted to perform an integer multiplication I had to use LSL(i, 3) instead of i * 8.
The use of CHAR as a poor man’s substitute for unsigned BYTE just compounded the situation.
Fortunately nearly all of that is behind us now that Oberon-07 has BYTE, ROR, LSR and ASR. All that is needed now perhaps to complete the picture is MASK / MSK?
More information about the Oberon