[Oberon] Negative integer literals in Oberon

Arthur Yefimov artur.efimov at gmail.com
Sat Apr 25 17:08:28 CEST 2020


While developing the compiler[1], we got a question
whether it is possible to write the following:

PROCEDURE DWord(n: INTEGER);
...
DWord (90909090H)

(where INTEGER is 32-bit).

Some compilers give an error (i.e. VOC), while this works in the
Project Oberon (2013) compiler. This would turn out to be quite convenient,
because the purpose of DWord in our code was to write 4 bytes to the file
given as INTEGER (using little-endian byte order).

DWord has the following implementation (module Generator[2]):

PROCEDURE DWord (n: INTEGER);
BEGIN
  Files.Write (r, CHR (n MOD 100H));
  Files.Write (r, CHR (n DIV 100H MOD 100H));
  Files.Write (r, CHR (n DIV 10000H MOD 100H));
  Files.Write (r, CHR (n DIV 1000000H))
END DWord;

The Oberon language report does not indicate that literal 90909090H
should be considered an error if INTEGER has 32 bits.

In this experiment, an online RISC emulator[3] was used.

References:
[1] https://github.com/kekcleader/oberon
[2] https://github.com/kekcleader/oberon/blob/master/Mod/Generator.Mod
[3]
http://schierlm.github.io/OberonEmulator/emu-wasm.html?image=FullDiskImage&width=1024&height=768
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.inf.ethz.ch/pipermail/oberon/attachments/20200425/98af3316/attachment.html>


More information about the Oberon mailing list