[Oberon] PO2013 compiler and SET operations

Hellwig Geisse hellwig.geisse at mni.thm.de
Wed Jul 29 18:03:15 CEST 2020


Michael,

On Mi, 2020-07-29 at 17:08 +0200, Michael Schierl wrote:
> 
>   PROCEDURE SetDiff(a, b:SET): SET;
>   BEGIN
>   RETURN a - b
>   END SetDiff;
> 
>   PROCEDURE Mask1(a, b: INTEGER): INTEGER;
>   BEGIN
>   RETURN SYSTEM.VAL(INTEGER, SetDiff(SYSTEM.VAL(SET, a), {b .. b + 7}))
>   END Mask1;
> 
>   PROCEDURE Mask2(a, b: INTEGER): INTEGER;
>   BEGIN
>   RETURN SYSTEM.VAL(INTEGER, SYSTEM.VAL(SET, a) - {b .. b + 7})
>   END Mask2;
> 

this seems to be an erroneous translation of the set difference
operator, as far as I can see. This operator essentially gets
compiled to an "and negated" (ANN) instruction. The instruction
sequence for SetDiff is correct, it ends with "ANN R0,R0,R1"
(result in R0, a in R0, b in R1). But the instruction sequence
for Mask2 ends with "ANN R0,R1,R1", which yields 0 in R0
independent of the value in R1. The correct sequence should be
"ANN R0,R1,R0". I explored this with Andreas' Extended Oberon
compiler.

Hellwig


More information about the Oberon mailing list