[Oberon] Standalone BootLoader format

Tomas Kral thomas.kral at email.cz
Thu May 14 12:07:04 CEST 2020


> I don’t know about the compiler you are using (probably the Oberon-0)

Yes, Oberon-0 emitting instructions into an array code[0..pc]. It
produces standalone code, that can be executed in a small RISC
emulator module (it sets R[13] := pc, i.e. past the last instruction
before execution).

OSP.Compile @ OSG.Decode
OSG.Execute ~
OSG.StoreBoot (* RISC standalone code *)

MODULE TestLED;
  VAR x, y, z: INTEGER;
BEGIN z := 0;
  REPEAT LED(z); x := 1000;
    REPEAT y := 1000;
      REPEAT y := y-1 UNTIL y = 0;
      x := x-1
    UNTIL x = 0;
    z := z+1
  UNTIL FALSE
END TestLED.

I have added StoreBoot to get the executable, and it sets SB to PC after
the last instruction.

PROCEDURE Close*;
  BEGIN Put1(Mov, 0, 0, 0); Put3(0, 7, 0); Put1(Mov, SB, 0, (pc+1)*4);
END Close;

OSG.Decode
   0 E7000000   B       0
   1 40000000   MOV R0 R0       0
   2 A0D00008   STW  R0 SB       8
   3 80D00008   LDW R0 SB       8
...
  27 40000000   MOV R0 R0       0
  28 C7000000   B R0
  29 4D000074   MOV, SB, R0    116

When storing to file, I store last instruction in code[pc+1] as first,
then followed by code[0] .. code[pc].

Note file is 116 bytes long.

So it becomes
   0 4D000074   MOV, SB, R0    116
   1 E7000000   B       0
   2 40000000   MOV R0 R0       0
   3 A0D00008   STW  R0 SB       8
   4 80D00008   LDW R0 SB       8
...
  27 40000000   MOV R0 R0       0
  28 C7000000   B R0

In hope I managed to set SB to a sensible value, not overwriting the
standalone code. 

After booting with BRAM BootLoad, it does not work. I must still
misunderstand something???

-- 
Tomas Kral <thomas.kral at email.cz>


More information about the Oberon mailing list