[Oberon] Constant folding, Re: Bit-fiddling: SETs and type casts in Oberon-07

Andreas Pirklbauer andreas_pirklbauer at yahoo.com
Tue Aug 9 17:44:40 CEST 2022


If you put extra brackets around the last two calls to ORD, as in:

    PROCEDURE P;
       VAR ch: CHAR;
    BEGIN ch := CHR(ORD(ch) - (ORD("a") + ORD("A”)))
    END P;

then the official Oberon-07 compiler does actually fold the constants:

   2   90E00004  LDR  R0 SP       4
   3   40090020  SUB  R0  R0     32         # ORD(“a) - ORD(“A”)  =  97 - 65  = 32 --> constants folded
   4   B0E00004  STR   R0 SP       4





More information about the Oberon mailing list