> In section 8.1 on page 104, the line > > R13 base address for variables in the current module SB (static base) > > now needs changing to something like > > R13 reserved: static base (base address for module variables); or unused > > but everything else is ok, right? > > I couldn't find any other mentions of SB explicitly, even in the > description of linking. I searched for “SB” in the PDF of the book Project Oberon 2013 and found these places: 1. Section 8.1. on page 104, as you have stated above 2. Section 12.2. on page 15 of “1 PO Applications” 2.a. The text "Global variables are allocated in the module's data section and the respective base address register is SB (Static Base, see Chapter 6).” now needs changing to somelink "Global variables are allocated in the module's data section and the respective base address register is any register RH used as a “static base” (see Chapter 6).” 2.b. The text at the bottom of p.15 "Memory instructions compute the address as the sum of a register (base) and an offset constant. Local variables use the stack pointer SP (R14) as base, global variables the static base SB (R13) Every module has its own SB value, and therefore access to global (and imported) variables requires two instructions, one for fetching the base value, and one for loading or storing data. If the compiler can determine, whether the correct base value has already been loaded into the SB register, the former instruction is omitted. The first 7 sample patterns contain global variables only, and their base SB is assumed to hold the appropriate value. Parameters of branch instructions denote jump distances from the instruction's own location (PC-relative)." also needs some changing. 2.c. Practically all code patterns (Pattern 1 - Pattern 17) starting on p.16 of “1 PO Applications” and their associated explanations use SB. I suppose one could recompile all these examples and update the generated code in each case, and also the text below each of these patterns. 3, Section 12.7.1. Expressions on page 43 of “1 PO Applications” reads 3.a. The text on p.43 "Expressions consist of operands and operators. They are evaluated and have a value. First, a number of make-procedures transform objects into items (see Section 12.3.2). The principal one is MakeItem. Typical objects are variables (class, mode = Var). Global variables are addressed with base register SB (x.r = 13), local variables with the stack pointer SP (x.r = 14). VAR-parameters are addressed indirectly; the address is on the stack (class, mode = Par, Ind). x.a is the offset from the stack pointer.” needs changing to “are addressed with a base register” or similar. 3.b. The text on p.43 "Base address SB is, as the name suggests, static. But this holds only within a module. It implies that on every transfer to a procedure in another module, the static base must be adjusted. The simplest way is to load SB before every external call, and to restore it to its old value after return from the procedure. We chose a different strategy: loading on demand (see below: global variables).” needs changing. 3.c. invalSB is used at multiple places, e.g. on p.46. Needs to be eliminated. 4. Section 12.7.9. Import and export, global variables references SB multiple times, for example on p.50: "It is therefore necessary in the general case to use a base address in conjunction with the offset. We use a single register for holding the static base (SB, R13). This register need be reloaded for every access to an imported variable. However, the compiler keeps track of external accesses; if a variable is to be accessed from the same module as the previous case, then reloading is avoided (see procedure GetSB and global compiler variable curSB).” or, also on p.50 “ LDR SB, MT, modno*4 base address of data section LDR R0, SB, offset offset computed by the loader from object's export number “ 5. Section 12.7.10. Traps references SB (still p.50, at the very bottom) "ADD R0, SP, p address of p ADD R1,SB, tag type tag BLR 7, 0CH branch and link unconditionally through R12 (MT), trap number 0 These are all the ones I found. No guarantee for completeness..
participants (1)
-
Andreas Pirklbauer