3 ms·
Waste 0th element or reuse it for something like length (hello, pascal strings). Another option is using base_address - element_size as your array value. Anothe
by vbezhenar 4y ago
Waste 0th element or reuse it for something like length (hello, pascal strings). Another option is using base_address - element_size as your array value. Another option is using +element_size for all array accesses, assembly languages usually have this instruction. There’re many options to use 1-based indexing without sacrificing performance.
- xg15 4y ago> assembly languages usually have this instruction Is that so? I wasn't aware of that.
- vbezhenar 4y agoAt least x86_64 can put something like `ptr[index * 4 + 4]` in one instruction (assuming that variable values are in registers). Not completely sure about ARM.
- chinabot 4y agonewer pascal strings are #0 terminated, original pascal strings were 255 chars max with string[0] being the string length, they were also not Unicode friendly, newer pascal compilers still support this as the shortstring type. I use pascal style strings in my embedded C library I wrote in 1989 much more efficient on 8/16-bit systems