<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><br /></p>
<p>To be clear - I would like VOC to allow myint32 := 90909090H, but VOC's support of 64 bit literals gets in the way.</p>
<p>My advice therefore is that if you never plan to support integers of more than 32 bits, go ahead and allow myint := 90909090H.</p>
<p>If you plan to add support for 64 bit integers later, you will need to work around the problems I described below. I cannot see how to do that, but I would love a solution.</p>
<p>-- Dave.</p>
<p>On 2020-04-26 10:14, Joerg wrote:</p>
<blockquote type="cite" style="padding: 0 0.4em; border-left: #1010ff 2px solid; margin: 0"><!-- html ignored --><!-- head ignored --><!-- meta ignored -->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> </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> </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> </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" style="padding: 0 0.4em; border-left: #1010ff 2px solid; margin: 0">Am 26.04.2020 um 10:25 schrieb Joerg <joerg.straube@iaeth.ch>:<br /><br /></blockquote>
</div>
<blockquote type="cite" style="padding: 0 0.4em; border-left: #1010ff 2px solid; margin: 0">
<div dir="ltr">Chris
<div> </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> </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> </div>
<div>br</div>
<div>
<div dir="ltr">
<div>Jörg</div>
</div>
<div dir="ltr"><br />
<blockquote type="cite" style="padding: 0 0.4em; border-left: #1010ff 2px solid; margin: 0">Am 26.04.2020 um 09:28 schrieb dave@brownsmeet.com:<br /><br /></blockquote>
</div>
<blockquote type="cite" style="padding: 0 0.4em; border-left: #1010ff 2px solid; margin: 0">
<div dir="ltr">
<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 style="padding: 0 0.4em; border-left: #1010ff 2px solid; margin: 0;">
<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. </span></p>
<p class="MsoNormal"><span style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d; mso-fareast-language: EN-US;"> </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.</span></p>
<p class="MsoNormal"><span style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d; mso-fareast-language: EN-US;"> </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.</span></p>
<p class="MsoNormal"><span style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d; mso-fareast-language: EN-US;"> </span></p>
<p class="MsoNormal"><span style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d; mso-fareast-language: EN-US;">Regards,</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</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</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</span></p>
<p class="MsoNormal"><span style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d; mso-fareast-language: EN-US;"> </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</span></p>
</div>
</div>
<p class="MsoNormal"> </p>
<div>
<p class="MsoNormal">While developing the compiler[1], we got a question</p>
<div>
<p class="MsoNormal" style="margin-bottom: 12.0pt;">whether it is possible to write the following:</p>
<div>
<p class="MsoNormal">PROCEDURE DWord(n: INTEGER);<br />...<br />DWord (90909090H)</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</p>
</div>
<div>
<p class="MsoNormal">Project Oberon (2013) compiler. This would turn out to be quite convenient,</p>
</div>
<div>
<p class="MsoNormal">because the purpose of DWord in our code was to write 4 bytes to the file</p>
</div>
<div>
<p class="MsoNormal">given as INTEGER (using little-endian byte order).</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">DWord has the following implementation (module Generator[2]):</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</p>
</div>
<div>
<p class="MsoNormal">should be considered an error if INTEGER has 32 bits.</p>
</div>
<div>
<p class="MsoNormal"><br />In this experiment, an online RISC emulator[3] was used.</p>
</div>
</div>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">References:</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></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></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></p>
</div>
</div>
</div>
</div>
<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></div>
</blockquote>
</div>
</div>
</blockquote>
</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>