[Oberon] Branch instruction, program counter and link register

Wim Niemann niemannw at xs4all.nl
Tue Dec 19 14:49:25 CET 2017


Hi Srinivas,

Normally, when a procedure is called, the current program counter is saved on stack.
RISC-5 does not have such a specific 'PUSH PC' but can save to R15 in a branch instruction.
If the procedure does not make calls itself (a leaf procedure), R15 does not change and the call/return is extremely efficient.
Also, the save to R15 makes for a smaller and simpler instruction set, the usual push and pop (or 'store and increment') instructions are not present.

If every branch instruction in a procedure's body would save PC+4 to R15, then R15 must always be saved on stack on procedure entry and the fast 'leaf procedure' entry/return is not possible anymore.

I believe the current Oberon compiler does not optimize leaf procedure calls and pushes R15 on stack anyway (ORG.Enter).

So, actually in the current sitution there won't be any difference but for a few transistors switching to latch the PC address in R15.

Wim Niemann



On Tue, 19 Dec 2017 18:18:32 +0530
Srinivas Nayak <sinu.nayak2001 at gmail.com> wrote:

> Dear All,
> 
> In RISC-5, why not every branch instruction saves PC+4 to R15?
> Any disadvantages?
> 
> 
> With thanks and best regards,
> 
> Yours sincerely,
> Srinivas Nayak
> 
> Home: http://www.mathmeth.com/sn/
> Blog: http://srinivas-nayak.blogspot.in/
> --
> Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
> https://lists.inf.ethz.ch/mailman/listinfo/oberon


More information about the Oberon mailing list