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

Andreas Pirklbauer andreas_pirklbauer at yahoo.com
Wed Dec 19 21:01:01 CET 2018

ADDENDUM: Oups.. I mean to respond to *this* comment actually:

   > I suppose it would be possible as well to first pass the parameters
   > beginning with R0 and then directly put procedure address in next free register.


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