[Oberon] Negative integer literals in Oberon
artur.efimov at gmail.com
Sat Apr 25 17:08:28 CEST 2020
While developing the compiler, we got a question
whether it is possible to write the following:
PROCEDURE DWord(n: INTEGER);
(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):
PROCEDURE DWord (n: INTEGER);
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))
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 was used.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Oberon