[Oberon] Standalone BootLoader format

Tomas Kral thomas.kral at email.cz
Tue May 12 22:18:39 CEST 2020


Andreas,

Another exercise. Same standalone moudule, now compiled with Oberon-0
compiler.

(* Standalone module booted over serial, with BRAM loader *)
MODULE* Counter;
  VAR x, y, z: INTEGER;
BEGIN LED(1); 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 Counter.

(* BRAM Loader sets
   MTOrg = 20H; MemLim = 0E7EF0H; stackOrg = 80000H;
   SYSTEM.LDREG(SP, stackOrg); *)

(* Stack SP := SP-4, save LINK reg *)
   0 4EE90004   SUB SP SP       4
   1 AFE00000   STW  LNK SP       0
(* LED(1), mem[-60] := 1*)
   2 40000001   MOV R0 R0       1
   3 5100FFC4   MOV R1 R0     -60
   4 A0100000   STW  R0 R1       0
(* z := 0, mem[SB+8] := R0 *)
   5 40000000   MOV R0 R0       0
(* Static base SB := mem[0+6] *)
   6 8D000006   LDW SB R0       6
   7 A0D00008   STW  R0 SB       8
...
(* x := 1000, mem[SB+0] := R0 *)
  11 400003E8   MOV R0 R0    1000
  12 A0D00000   STW  R0 SB       0
(* y := 1000, mem[SB+4] := R0 *)
  13 400003E8   MOV R0 R0    1000
  14 A0D00004   STW  R0 SB       4
...
(* Restore and branch to LINK reg *)
  31 8FE00000   LDW LNK SP       0
  32 4EE80004   ADD SP SP       4
  33 C700000F   B LNK

Why we initialise SB from mem[6] ???
Any limits on globals here???

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


More information about the Oberon mailing list