[Oberon] Standalone BootLoader format

Andreas Pirklbauer andreas_pirklbauer at yahoo.com
Wed May 13 11:25:14 CEST 2020


    > I have older Oberon=0, compiler, too. That starts with B (PC+off+1), but
    > I seem to miss in the code an instruction setting SB to a reasonable value.
    ..
    > Most confusion arises here, that in PO2013, I cannot clearly see how SB
    > is handled, for me is rather obscured.

The documentation in the book Project Oberon 2013 s indeed sometimes lagging
behind or quite simply no longer in 100% snyc the latest implementation on the website.

That’s a bit unfortunate. But the book simply is not updated each time a change is made.

PS: I noted that you have referred a few times to the SB register in previous posts.

Please note that in PO 2013 the SB = R13 register is no longer used since
July 20th, 2018. So the book is indeed out of date in this regard as well.

Before July 20th, 2019, ORG.GetSB and ORG.Header read:

  PROCEDURE GetSB(base: LONGINT);
  BEGIN
    IF (version # 0) & ((base # curSB) OR (base # 0)) THEN
      Put2(Ldr, SB, -base, pc-fixorgD); fixorgD := pc-1; curSB := base
    END
  END GetSB;

  PROCEDURE Header*;
  BEGIN entry := pc*4;
    IF version = 0 THEN code[0] := 0E7000000H-1 + pc; Put1a(Mov, SB, 0, VarOrg0); Put1a(Mov, SP, 0, StkOrg0)  (*RISC-0*)
    ELSE Put1(Sub, SP, SP, 4); Put2(Str, LNK, SP, 0); invalSB
    END
  END Header;

Here you can see how SB was set for standalone programs, namely via Put1a(Mov, SB, 0, VarOrg0).
For regular programs, GetSB generates an LD SB.. instruction, which is fixed up by the loader.

Since July 20th, 2019, ORG.GetSB and ORG.Header now read:

  PROCEDURE GetSB(base: LONGINT);
  BEGIN
    IF version = 0 THEN Put1(Mov, RH, 0, VarOrg0)                  (*no more SB used here!!!*)
    ELSE Put2(Ldr, RH, -base, pc-fixorgD); fixorgD := pc-1
    END
  END GetSB;

  PROCEDURE Header*;
  BEGIN entry := pc*4;
    IF version = 0 THEN code[0] := 0E7000000H-1 + pc;  Put1a(Mov, SP, 0, StkOrg0)  (*RISC-0*)
    ELSE Put1(Sub, SP, SP, 4); Put2(Str, LNK, SP, 0)
    END
  END Header;

So you can see that the SB = R13 register is not used AT ALL in PO 2013. Instead, RH is used, and
there is no more need to initialize SB to a reasonable value (namely VaroOrg0 = 0) in ORG.Header.

I don’t know about the compiler you are using (probably the Oberon-0 compiler described
in the book Compiler Construction), but if you you know the compiler well enough, you
can always figure out what is going on. Don’t rely too much on the book for little details
like that, for they may have changed in the official PO 2013 release, without updating
the book.











More information about the Oberon mailing list