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

Andreas Pirklbauer andreas_pirklbauer at yahoo.com
Wed Dec 19 20:53:00 CET 2018


  > How would you know which register to use, in advance, since evaluating
  > each parameter could involve expressions?

I was puzzled about this too a little initially... The reason why the register has
to be saved on the stack in this case is precisely because one does not know
in advance which register to use (as params may use any number of regs).

Perhaps another way to think about this is to distinguish the 2 cases:

A) In the case where the value of a procedure comes from, for example,
dereferencing a pointer (x.mode > ORB.Par in PrepCall), a register is
*already* involved for that procedure (x.mode = RegI in this example).
This register (e.g. R1) must be pushed onto the stack -- alongside the other
registers saved by SaveRegs (it'll be the last one) -- before parameters
are evaluated, and simply popped off it and loaded into the (now known)
next available register, e.g. R5, when the procedure is actually called. 

B) The case where *no* register is involved yet (x.mode <= ORB.Par), for
example when a global procedure variable is called (x.mode = ORB.Var)
is easy - as there is (naturally) no need to save anything on the stack in
PrepCall yet. The addresses of such procedures will simply be loaded into
the next available register in the normal way via load(x) in ORG.Call.


All this is rather cumbersome, but it comes about, because registers
must be allocated in a strict stack fashion..









More information about the Oberon mailing list