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

Andreas Pirklbauer andreas_pirklbauer at yahoo.com
Wed Dec 19 08:08:43 CET 2018


   > Right. If the procedure variable was not actually loaded before the
   > parameters were evaluated (ie the procedure was not the result of an
   > expression), no registers needed to be saved, so the save is explicitly avoided.

I presume you mean this is how the compiler distinguishes between regular
procedures and function procedures (which are part of an expression)?

   > It's only in the case where it was already loaded into a register
   > (detected by RH > 0 before the save), where it was therefore saved (first,
   > fortunately), and consequently needs to be explicitly restored.

Or when x.mode = RegI = 11, as In the sample program M below, where
RH > 0 for *both* function procedure ptr.f *and* regular procedure ptr.p
(which is not part of an expression).

In the second call ptr.f(“D”) in RunF2 below, RH is actually 2, not 1, in PrepCall.

-ap


  MODULE M;
    TYPE Procedure = PROCEDURE(a, b: INTEGER);  (*regular procedure*)
      Function = PROCEDURE(c: CHAR): INTEGER;  (*function procedure*)
      Ptr = POINTER TO Rec;
      Rec = RECORD p: Procedure; f: Function END ;

    VAR ptr: Ptr; res: INTEGER;

    PROCEDURE P(a, b: INTEGER); BEGIN END P;  (*regular procedure*)
    PROCEDURE F(c: CHAR): INTEGER; BEGIN RETURN 0 END F;  (*function procedure*)

    PROCEDURE RunP*;
    BEGIN ptr.p(1, 2)    (*x.mode = RegI = 11 and RH = 1 in PrepCall, x.mode = 10 = Reg in Call*)
    END RunP;

    PROCEDURE RunF1*;
    BEGIN res := ptr.f("C")   (*x.mode = RegI = 11 and RH = 1 in PrepCall, x.mode = 10 = Reg in Call*)
    END RunF1;

    PROCEDURE RunF2*;
    BEGIN res := ptr.f("C")   (*x.mode = RegI = 11 and RH = 1 in PrepCall, x.mode = 10 = Reg in Call*)
       + ptr.f("D")   (*x.mode = RegI = 11 and RH = 2 in PrepCall, x.mode = 10 = Reg in Call*)
    END RunF2;

  BEGIN NEW(ptr); ptr.p := P; ptr.f := F
  END M.

  ORP.Compile M.Mod/s ~



More information about the Oberon mailing list