Closed Spivoxity closed 5 years ago
I'm afraid I was in a pedantic mood when I finalised the built in functions. In Oberon-2 mode, ASH is provided, and in Oberon07 mode, it is replaced by LSL, LSR, ASR and ROR. Perhaps I should relax this in a future release and make all these available in both modes. In the meantime, three possible workarounds (none of which result in a single inlined instruction at runtime).
Replace LSL(x, y) with ASH(x, y) and ASR(x, y) with ASH(x, -y). [No equivalent for LSR or ROR].
Write a C primitive for each shift operator and link it in.
If you want LSR to be available in Oberon-2 code, write a module Shift and compile it in Oberon07 mode, then call Shift.Lsr from Oberon-2.
MODULE Shift;
PROCEDURE Lsr(x, y: INTEGER): INTEGER; RETURN LSR(x, y) END Lsr;
END Shift.
(yes, that is valid Oberon07 syntax).
Christian Kleinert writes: Had to check the language reports for Oberon-2 and Oberon07 to remember that LSL is not part of the Oberon-2 language, or is it? So if to enable it in Oberon-2 mode, maybe better via -x option (Enable language extensions) to stay as close to the language report as possible in standard mode? Prefer the separate Module though :-)
Actually, note that LSR is not listed in the latest Oberon07 report.
Not really a bug. But in the next release I will save fuss by providing all 5 functions in both modes.
Seems the LSL did not make it into the system, when compiling https://bitbucket.org/inkytonik/oberon0 I get a