<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /></head><body style='font-size: 12pt; font-family: Verdana,Geneva,sans-serif'>
<p>((Lapsed) VOC maintainer here.)</p>
<p>In both VOC and Oberon 2013, integer literals are parsed in the symbol parser (VOC :OPS.Mod or 2013:ORS.MOD) and stored in the symbol table as signed integer values.</p>
<p>Later, during expression compilation, their size is determined by the magnitude of their signed integer value.</p>
<p>The difference between Oberon 2013 and VOC is the largest integer type, which is 32 bit on Oberon 2013 and 64 bit in VOC.</p>
<p>The special handling that allows a hex literal with top bit set to be treated as a signed value happens at the time the literal is parsed as a symbol independent of what context it is being used in. (Consider e.g. 'CONST mask = 90909090H' - CONST parsing does not know whether this constant will be used in a 64 bit, 32 bit, 16bit or other context.)</p>
<p>VOC and Oberon 2013 do both allow the hex special case top bit set parsing behaviour, the difference being the integer literal size.</p>
<p>Thus VOC accepts myint64 := 9090909090909090H because 9090909090909090H is parsed as a negative 64 bit signed integer.</p>
<p>But VOC does not accept myint32 := 90909090H because 90909090H is parsed as a positive 64 bit signed integer. </p>
<p>VOC has no way to parse 90909090H as a negative 32 bit signed integer.</p>
<p> - I did wonder about adding a further suffix letter to indicate the intended size, but I couldn't satisfy myself that any solution was simple enough to be easy to understand.</p>
<p> - Note that this is independent of VOC's -Ox compatibility setting: that sets the default INTEGER size, not integer literal size - integer literals always support the largest available integer size which is SYSTEM.INT64 aka HUGEINT.)</p>
<p>-- Dave</p>
<p><br /></p>
<p>On 2020-04-25 22:52, Chris Burrows wrote:</p>
<blockquote type="cite" style="padding: 0 0.4em; border-left: #1010ff 2px solid; margin: 0"><!-- html ignored --><!-- head ignored --><!-- meta ignored --><!-- meta ignored -->
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d; mso-fareast-language: EN-US;">It all depends on what size (i.e. number of bits) INTEGER is defined as on the system you are using as to what range of numbers are valid INTEGERs. Since 2011, the range of INTEGER values is no longer defined in the Language Report; it is implementation-dependent. <!-- o ignored --></span></p>
<p class="MsoNormal"><span style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d; mso-fareast-language: EN-US;"><!-- o ignored --> </span></p>
<p class="MsoNormal"><span style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d; mso-fareast-language: EN-US;">In the Project Oberon (2013) RISC5 compiler, INTEGER is 32 bit so 90909090H is a valid INTEGER. Maybe you used the default (-O2) option in VOC? If so, INTEGER is 16 bit so 90909090H would be too large. Make sure you are compiling with the VOC –OC option instead if you want INTEGER to be treated as a 32 bit quantity.<!-- o ignored --></span></p>
<p class="MsoNormal"><span style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d; mso-fareast-language: EN-US;"><!-- o ignored --> </span></p>
<p class="MsoNormal"><span style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d; mso-fareast-language: EN-US;">Note that 9090H would be a negative number on a 16-bit INTEGER system but a positive number on a 32-bit INTEGER system.<!-- o ignored --></span></p>
<p class="MsoNormal"><span style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d; mso-fareast-language: EN-US;"><!-- o ignored --> </span></p>
<p class="MsoNormal"><span style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d; mso-fareast-language: EN-US;">Regards,<!-- o ignored --></span></p>
<p class="MsoNormal"><span style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d; mso-fareast-language: EN-US;">Chris Burrows<!-- o ignored --></span></p>
<p class="MsoNormal"><span style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d; mso-fareast-language: EN-US;">CFB Software<!-- o ignored --></span></p>
<p class="MsoNormal"><span style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d; mso-fareast-language: EN-US;">https://www.astrobe.com<!-- o ignored --></span></p>
<p class="MsoNormal"><span style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d; mso-fareast-language: EN-US;"><!-- o ignored --> </span></p>
<div style="border: none; border-left: solid blue 1.5pt; padding: 0cm 0cm 0cm 4.0pt;">
<div>
<div style="border: none; border-top: solid #E1E1E1 1.0pt; padding: 3.0pt 0cm 0cm 0cm;">
<p class="MsoNormal"><strong><span style="font-size: 11.0pt; font-family: 'Calibri','sans-serif';">From:</span></strong><span style="font-size: 11.0pt; font-family: 'Calibri','sans-serif';"> Oberon [mailto:oberon-bounces@lists.inf.ethz.ch] <strong>On Behalf Of </strong>Arthur Yefimov<br /><strong>Sent:</strong> Sunday, 26 April 2020 12:38 AM<br /><strong>To:</strong> oberon@lists.inf.ethz.ch<br /><strong>Subject:</strong> [Oberon] Negative integer literals in Oberon<!-- o ignored --></span></p>
</div>
</div>
<p class="MsoNormal"><!-- o ignored --> </p>
<div>
<p class="MsoNormal">While developing the compiler[1], we got a question<!-- o ignored --></p>
<div>
<p class="MsoNormal" style="margin-bottom: 12.0pt;">whether it is possible to write the following:<!-- o ignored --></p>
<div>
<p class="MsoNormal">PROCEDURE DWord(n: INTEGER);<br />...<br />DWord (90909090H)<!-- o ignored --></p>
<div>
<p class="MsoNormal"><br />(where INTEGER is 32-bit).<br /><br />Some compilers give an error (i.e. VOC), while this works in the<!-- o ignored --></p>
</div>
<div>
<p class="MsoNormal">Project Oberon (2013) compiler. This would turn out to be quite convenient,<!-- o ignored --></p>
</div>
<div>
<p class="MsoNormal">because the purpose of DWord in our code was to write 4 bytes to the file<!-- o ignored --></p>
</div>
<div>
<p class="MsoNormal">given as INTEGER (using little-endian byte order).<!-- o ignored --></p>
</div>
<div>
<p class="MsoNormal"><!-- o ignored --> </p>
</div>
<div>
<p class="MsoNormal">DWord has the following implementation (module Generator[2]):<!-- o ignored --></p>
</div>
<div>
<p class="MsoNormal"><br />PROCEDURE DWord (n: INTEGER);<br />BEGIN<br /> Files.Write (r, CHR (n MOD 100H));<br /> Files.Write (r, CHR (n DIV 100H MOD 100H));<br /> Files.Write (r, CHR (n DIV 10000H MOD 100H));<br /> Files.Write (r, CHR (n DIV 1000000H))<br />END DWord;<br /><br />The Oberon language report does not indicate that literal 90909090H<!-- o ignored --></p>
</div>
<div>
<p class="MsoNormal">should be considered an error if INTEGER has 32 bits.<!-- o ignored --></p>
</div>
<div>
<p class="MsoNormal"><br />In this experiment, an online RISC emulator[3] was used.<!-- o ignored --></p>
</div>
</div>
</div>
<div>
<p class="MsoNormal"><!-- o ignored --> </p>
</div>
<div>
<p class="MsoNormal">References:<!-- o ignored --></p>
</div>
<div>
<p class="MsoNormal">[1] <a href="https://github.com/kekcleader/oberon" target="_blank" rel="noopener noreferrer">https://github.com/kekcleader/oberon</a><!-- o ignored --></p>
</div>
<div>
<p class="MsoNormal">[2] <a href="https://github.com/kekcleader/oberon/blob/master/Mod/Generator.Mod" target="_blank" rel="noopener noreferrer">https://github.com/kekcleader/oberon/blob/master/Mod/Generator.Mod</a><!-- o ignored --></p>
</div>
<div>
<p class="MsoNormal">[3] <a href="http://schierlm.github.io/OberonEmulator/emu-wasm.html?image=FullDiskImage&width=1024&height=768" target="_blank" rel="noopener noreferrer">http://schierlm.github.io/OberonEmulator/emu-wasm.html?image=FullDiskImage&width=1024&height=768</a><!-- o ignored --></p>
</div>
</div>
</div>
</div>
<!-- html ignored --><br />
<div class="pre" style="margin: 0; padding: 0; font-family: monospace">--<br /> <a href="mailto:Oberon@lists.inf.ethz.ch">Oberon@lists.inf.ethz.ch</a> mailing list for ETH Oberon and related systems<br /> <a href="https://lists.inf.ethz.ch/mailman/listinfo/oberon" target="_blank" rel="noopener noreferrer">https://lists.inf.ethz.ch/mailman/listinfo/oberon</a></div>
</blockquote>
</body></html>