[TUHS] Array index history

Arthur Krewat krewat at kilonet.net
Thu Jun 8 23:55:49 AEST 2017


On 6/8/2017 9:49 AM, Random832 wrote:
> On Wed, Jun 7, 2017, at 15:15, Arthur Krewat wrote:
>> In the days when memory and clock cycles were costly, an extra decrement
>> or subtract was not something to be taken lightly :)
> You wouldn't need a decrement per access, because the base itself could
> still be stored as the address of the "0th" element (i.e. what would be
> the "-1th" in a 0-based system). It might add some extra complexity to
> the relocator, if it's not currently possible to have a reference
> outside the bounds of an object and/or with a negative offset, but
> statically linked programs (the only kind on V7 and earlier) did not do
> any runtime relocation.
>

Shortly after making that statement, it occurred to me that the 
preprocessor or assembler could take care of that easily.

Even better than worrying about whether arrays started at 0 or 1 in C 
would be to institute bounds checking in the first place :) But again 
would add lots of extra code that in the days of the origins of C was 
not something you wanted to add to the memory footprint.









More information about the TUHS mailing list