<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto">In earlier Oberon versions, variable integer size was supported: INTEGER and LONGINT. LONGINT is not officially supported in Oberon-07 but the compiler internally declares TYPE LONGINT = INTEGER.<div>The concept of variable integer size is not supported in Oberon-07 anymore. Every INTEGER has one (implementation dependent) size, be it 16 or 32 or 64 or ...</div><div><br></div><div>Syntactically and conceptionally, negative literals do not exist. Only results of calculations can be negative as they are done signed per report.</div><div>CONST neg = -1; is conceptionally the result of subtracting the literal 1 from 0, and NOT the literal -1.</div><div><br></div><div>If you use the hex suffix H to fill up the bits of the underlying INTEGER, you need to know the INTEGER size and are per definition in the grey, non-portable, implementation-dependent area of coding</div><div><br></div><div>If you use the hex suffix H to specify a (unsigned) 32 bit value for low level modules that work with 32 bits (on disc or memory or so) the size of the INTEGER does not matter (as long as it’s 32 bits or larger of course) as your low level module have to treat the passed values MOD 100000000H anyhow.</div><div><br><div dir="ltr">br<br><div>Jörg</div></div><div dir="ltr"><br><blockquote type="cite">Am 26.04.2020 um 10:25 schrieb Joerg <joerg.straube@iaeth.ch>:<br><br></blockquote></div><blockquote type="cite"><div dir="ltr"><meta http-equiv="content-type" content="text/html; charset=utf-8">Chris<div><br></div><div>1) b := i; is allowed, right?</div><div>2) b := i; does not generate a range check, right?</div><div>3) i := 511; b := i; </div><div><br></div><div>If 3) doesn’t generate a range check, but you want to be compliant to the report, you implement the assignment as b := i MOD 256;</div><div>as any value MOD 256 is between 0..255.</div><div><br></div><div>br</div><div><div dir="ltr"><div>Jörg</div></div><div dir="ltr"><br><blockquote type="cite">Am 26.04.2020 um 09:28 schrieb dave@brownsmeet.com:<br><br></blockquote></div><blockquote type="cite"><div dir="ltr"><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<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>
<span>--</span><br><span>Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems</span><br><span>https://lists.inf.ethz.ch/mailman/listinfo/oberon</span><br></div></blockquote></div></div></blockquote></div></body></html>