[Oberon] Assumed issue in the Lola-2 compiler

rochus.keller at bluewin.ch rochus.keller at bluewin.ch
Sun Apr 14 19:41:48 CEST 2019

Thank you all for your feedback and support.

@ Paul Reed: 
Unfortunately I'm not proficient in Oberon and naively assumed it's modulo operator would behave the same as the corresponding C operator; I will replace it with "int _MOD(int a, int b) { return ( a % b + b ) % b; }" instead to get a positive value in every case. But even with your clarifications I still think the comment "x >= 0" applies. The critical statement is "x := x DIV 10H"; if x=-1, then I would assume the result of this assignment would be zero, or am I wrong? 

@ Jörg Straube: 
>> be aware that the Lola compiler in Oberon supports unsigned values!
I'm fully aware; that's why I assumed that the 0FFFFFFFFH WORD literal would translate to a -1 LONGINT which Paul confirmed.
>> If you used the % operator while porting to C, this might not hold. Use & instead.
You're right; using the % operator was a naive implementation. But I have to use something like "int _MOD(int a, int b) { return ( a % b + b ) % b; }" instead of just & so it works for all combinations of positive/negative arguments, or am I wrong?
>> As I wrote yesterday, add a length to all constant values in MouseP.Lola.
I considered it, but of course I prefer to create a Lola compiler version which can correctly handle all cases supported by the Lola-2 language; your approach would require a factual language change.


More information about the Oberon mailing list