Hi again guys.
I'm still learning Z80 ASM, so I've been looking at some sample code around here. The thing is I usually use a lot of look-up tables in my programs, and it seems that the Z80 lacks an efficient way to load information from them.
All codes I've seen that use tables have loaded the index of the element into hl and then added the base address of the table. That seems very slow. in 6502 ASM, I'm used to loading values from tables using 8-bit index registers, and the 16-bit base address goes along with the load intruction (or can also be in RAM, wich is usefull for big tables). It's simple and fast, 'cause there is no add, just load the index and load the value from the table.
Now, is that really true that you must perform an addition (worse, a 16-bit addition) to find the location of an element in a table? I can only imagine how bad it gets when you are working with multiple-byte values, where adding the base address to the element index is not enough, you'd also have to multiply the index of the element by the number of bytes of each element. Seems dead slow.
Doesn't the Z80 have a couple of index registers? I didn't find much info on how they work, and no one seems to use them. I'm assuming they aren't of much use, as the gameboy CPU is a modified Z80 that doesn't have them.
Any thoughts on this?