[Oberon] PO2013 compiler and SET operations
Jörg
joerg.straube at iaeth.ch
Thu Jul 30 07:05:22 CEST 2020
Hi all
I think ORG.Set*(VAR x, y: Item) is the culprit.
Currently, in the end it is
IF x.mode = ORB.Const THEN
IF x.a # 0 THEN Put1(Xor, y.r, y.r, -1); Put1a(And, RH-1, y.r, x.a) END ;
x.mode := Reg; x.r := RH-1
ELSE DEC(RH); Put0(Ann, RH-1, x.r, y.r)
END
But is should be
IF x.mode = ORB.Const THEN
IF x.a # 0 THEN Put1(Xor, y.r, y.r, -1); Put1a(And, RH-1, y.r, x.a) END ;
x.mode := Reg;
ELSE DEC(RH); Put0(Ann, RH-1, x.r, y.r)
END;
x.r := RH-1
br
Jörg
Am 29.07.20, 18:03 schrieb "Oberon im Auftrag von Hellwig Geisse" <oberon-bounces at lists.inf.ethz.ch im Auftrag von hellwig.geisse at mni.thm.de>:
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
--
Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
https://lists.inf.ethz.ch/mailman/listinfo/oberon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.inf.ethz.ch/pipermail/oberon/attachments/20200730/d0f8a3d4/attachment.html>
More information about the Oberon
mailing list