[Oberon] Why is RSC string data word-aligned?

Jörg joerg.straube at iaeth.ch
Sun Jan 31 22:59:18 CET 2021


Sorry, for my confusion mixing up „word-alignment“ and „multiple of four“.
Indeed as Paul pointed out, the string block is not necessarily word-aligned in rsc file but the length of the string block is currently a multiple of four and can contain consecutive 0X.
Firstly, the module loader reads several module names to be imported. The length of these names are not in multiple of four.
The type descriptors, variable space and strings however are all items with length in multiple of four. As the destination address „p“ (where these blocks are stored in memory) is word-aligned the loader can just read these blocks without additional logic for word-alignment.

If we decided to write the string block not in multiple of four, the loader would need additional code to guarantee word-alignment.

Br, Jörg

> Am 31.01.2021 um 11:42 schrieb Jörg <joerg.straube at iaeth.ch>:
> Yes, it is word-aligned in the compiler and in the .rsc file, but for strings we CAN NOT take benefit of it during file reading, as the endianess is not defined.
> Once in memory, we can copy words as the undefined endianess does not interfere anymore.
> 
> br. Jörg
> 
>> Am 31.01.2021 um 11:11 schrieb Andreas Pirklbauer <andreas_pirklbauer at yahoo.com>:
>> 
>> 
>>> The unaligned data in a .rsc file is, I agree, unfortunate, as it could
>>> have been aligned relatively easily and then data could have been
>>> copied into memory a word at a time.
>> 
>> Isn’t any data - including string data . already word-aligned in the
>> compiler (and therefore also in the .rsc file)?
>> 
>> 1. The array ORG.str itself is word-aligned, because...
>> 
>>   - Modules.AllocPtr is word-aligned (see Modules.Load)
>>   - Modules.DescSize is a multiple of 4, so mod.data is word-aligned
>>   - All type descriptors are word-aligned (see ORG.BuildTD)
>>   - All variables are word-aligned (see ORG.Declarations)
>>   - All strings are word-aligned (see ORG.MakeStringItem)
>> 
>> 2. ORG.MakeStringItem
>> 
>>  WHILE strx MOD 4 # 0 DO str[strx] := 0X; INC(strx) END
>> 
>> 3. ORP.Declarations
>> 
>>   IF sym = ORS.var THEN
>>       ...
>>       IF tp.size > 1 THEN varsize := (varsize + 3) DIV 4 * 4 (*align*) END ;
>>>>   END ;
>>   varsize := (varsize + 3) DIV 4 * 4;
>> 
>> 
>> 
>> 
>> 
>> --
>> Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
>> https://lists.inf.ethz.ch/mailman/listinfo/oberon


More information about the Oberon mailing list