From mboxrd@z Thu Jan 1 00:00:00 1970 From: krewat@kilonet.net (Arthur Krewat) Date: Wed, 7 Jun 2017 15:15:05 -0400 Subject: [TUHS] Array index history In-Reply-To: <016301d2dfc0$b098e250$11caa6f0$@ronnatalie.com> References: <23afd785-e260-75ca-5c46-77c62fbcf3cd@kilonet.net> <016301d2dfc0$b098e250$11caa6f0$@ronnatalie.com> Message-ID: <57dce8ab-153d-89ce-91d6-07d9f01f7d6b@kilonet.net> 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 :) ak