Is it possible to have a computed jump in C? Maybe a jumptable with hundereds of entries. Don't want a switch case structure because every decision brings a time penalty. :-)
make a table of function pointers and access it indexed. fine for ARM, awful for the '51. Erik
make a table of function pointers and access it indexed. Sorry, i'am a absoulute beginner in C but i have 10 years 8051-assembler experience. For 8051 i could write it with closed eyes, but in C i need an example :-)
So, do you want this for C-ARM or C51?
ARM7 :-)
Don't want a switch case structure because every decision brings a time penalty. The compiler _should_ translate large switch/case statements into jump tables, instead of making lots of single decisions, by the way.
Most C compilers (and their optimizers) will implement switches as either a series of tests or a jump table depending on density of labels, number of labels, and so on. Ideally, an embedded compiler would have a pragma to let you force the implementation when you care. Sometimes, you want the constant-time execution of a jump table. Sometimes you might even prefer to priority-order your cases so that the earlier ones do execute first. You can, of course, always manually implement an if-then-else series, or else a table of function pointers, as desired.
Just wondering: With an ARM, is it likely that a jump table would be more or less code efficient than an array of function pointers?