[TUHS] Array index history
krewat at kilonet.net
Thu Jun 8 05:15:05 AEST 2017
On 6/7/2017 3:03 PM, Ron Natalie wrote:
>> Why go to the trouble of decrementing the index to retreive the first entry?
> What makes you think that you have to decrement the index. Don't get sucked up in the idiotic C implementation of an array. Arrays can be efficiently implemented no matter where the index starts.
In the days when memory and clock cycles were costly, an extra decrement
or subtract was not something to be taken lightly :)
On the other hand, I can see that you could solve this in the
preprocessor. In my example, just make it:
MOV AL, [SI + (ARRAY1 - FIRSTELEMENT)]
And let the assembler deal with it.
Still, there's something oddly "artificial" about that, again from the
machine language point of view. There's nothing "idiotic" about it IMHO.
It's just the way processors actually work.
Of course, if you're really into abstraction, well, to each his own :)
More information about the TUHS