[Oberon] Standalone BootLoader format
Tomas Kral
thomas.kral at email.cz
Thu May 14 15:08:29 CEST 2020
> Prof. Wirth's compilers store instructions into an array
> 0..(pc-1) and pc is reported as the size.
Yes, and I try setting SB pointing to pc when storing this array to
file. This mimics what RISC.Mod emulator does R[13] := pc*4 prior
execution.
> the first
> instruction is a branch to the body over any procedures
> there are a further seven instructions reserved, e.g. for a branch
> when using interrupts in a von-Neumann (as opposed to modified >
> Harvard) setup.
Actually I thought we are branching over boot limits, did not know about
interrupts in a von-Neumann
0 A branch instruction to the initializing body of module Modules (* set by OLR.Link *)
12 The limit of available memory
16 The address of the end of the module space loaded
20 The current root of the links of loaded modules
24 The current limit of the module area
> Note that the serial bootfile format is different from
> See BootLoad.Mod for details.
Yes, now it works. But I have two jumps, not neat, but with more
understanding, I can improve further, to have a single branch.
0 E7000007 B 7 (* currently hardcoded *)
1 00000000 (* boot limit area *)
2 00000000 (* 7 words *)
3 00000000
4 00000000
5 00000000
6 00000000
7 00000000
(* setting SB past the code block *)
8 4D000090 MOV SB R0 144
(* branch over procedures, no procedures := 0 *)
9 E7000000 B 0
10 40000000 MOV R0 R0 0
11 A0D00008 STW R0 SB 8
12 80D00008 LDW R0 SB 8
13 5100FFC4 MOV R1 R0 -60
14 A0100000 STW R0 R1 0
15 400003E8 MOV R0 R0 1000
16 A0D00000 STW R0 SB 0
17 400003E8 MOV R0 R0 1000
18 A0D00004 STW R0 SB 4
19 80D00004 LDW R0 SB 4
20 40090001 SUB R0 R0 1
21 A0D00004 STW R0 SB 4
22 80D00004 LDW R0 SB 4
23 40090000 SUB R0 R0 0
24 E9FFFFFA BNE -6
25 80D00000 LDW R0 SB 0
26 40090001 SUB R0 R0 1
27 A0D00000 STW R0 SB 0
28 80D00000 LDW R0 SB 0
29 40090000 SUB R0 R0 0
30 E9FFFFF2 BNE -14
31 80D00008 LDW R0 SB 8
32 40080001 ADD R0 R0 1
33 A0D00008 STW R0 SB 8
34 E7FFFFE9 B -23
35 40000000 MOV R0 R0 0
36 C7000000 B R0
PROCEDURE Close*; (* added SB *)
BEGIN Put1(Mov, 0, 0, 0); Put3(0, 7, 0); (* setting SB *) Put1(Mov, SB, 0, (pc+8)*4);
END Close;
In the OSG.Mod there is a `dc := 0' what is the meaning; Code displacement???
Perhaps I could learn to use.
PROCEDURE StoreBoot*;
VAR F: Files.File; R: Files.Rider; i: INTEGER;
BEGIN
F := Files.New("Risc.bin"); Files.Set(R, F, 0);
Texts.WriteString(W, "store Risc.bin"); Texts.Append(Oberon.Log, W.buf);
Files.WriteInt(R, 0E7000007H); (* B 7 relative*)
FOR i := 1 TO 7 DO Files.WriteInt(R, 0H) END ; (* 7 words reserved *)
Files.WriteInt(R, code[pc-1]); DEC(pc);
i := 0; REPEAT Files.WriteInt(R, code[i]); INC(i)
UNTIL i = pc; Files.Register(F);
Texts.WriteString(W, " done.");
Texts.WriteLn(W); Texts.Append(Oberon.Log, W.buf)
END StoreBoot;
--
Tomas Kral <thomas.kral at email.cz>
More information about the Oberon
mailing list