| ??? 02/14/01 14:31 Read: times |
#9316 - RE: use of multiply in large data arrays |
Basically an array of pointers is the 'standard' compromise between flexibility and speed. A better way that works with SOME compilers is a switch statement where the cases are separated by 2 (not enum separation by 1) Quality compilers will change that to a table driven jmp @a+dptr (note we get a 16 bit addition 'for free').
so: switch (table_number) case four: ptr = &table_4 break; turns into mov a,Table_number mov dptr,#CompilerGeneratedTableAddress jmp @a+dptr four: mov dptr,#table_4 jmp continue If your speed is not extremely critical, you can use increment by one (enum), it will just cost a shift after the mov a,Table_number. A cheap compiler will multiply here, but such a compiler will not do the jmp @a+dptr trick either. Of course, you can do the right thing and code it in assembler, that will allow you to enforce the fastest, most efficient way to do it instead of letting some distant person who wrote the compiler make the decision for you. Have fun, kiss your wife/girlfriend now you have fresh breath Erik |



