[Oberon] Question on ORG.SaveRegs / ORG.RestoreRegs in the FPGA Oberon compiler

Andreas Pirklbauer andreas_pirklbauer at yahoo.com
Mon Feb 18 06:38:47 CET 2019


As a purely pedagogical addendum: A possible student exercise would be to rewrite
ORG assuming *no* procedure variables existed in the language:

    PROCEDURE PrepCall*(VAR x: Item; VAR r: LONGINT);
      BEGIN (*x.type.form = ORB.Proc*) r := RH;
        IF RH > 0 THEN SaveRegs(RH); RH := 0 END
      END PrepCall;

    PROCEDURE Call*(VAR x: Item; r: LONGINT);
    BEGIN (*(x.mode = ORB.Const) & (x.type.form = ORB.Proc)*)
      IF x.r >= 0 THEN Put3(BL, 7, (x.a DIV 4)-pc-1)
      ELSIF pc - fixorgP < 1000H THEN
        Put3(BL, 7, ((-x.r) * 100H + x.a) * 1000H + pc-fixorgP); fixorgP := pc-1
      ELSE ORS.Mark("fixup impossible")
      END ;
      IF x.type.base.form = ORB.NoTyp THEN (*procedure*) RH := 0
      ELSE (*function*)
        IF r > 0 THEN Put0(Mov, r, 0, 0); RestoreRegs(r) END ;
        x.mode := Reg; x.r := r; RH := r+1
      END
    END Call;



More information about the Oberon mailing list