??? 06/24/05 23:13 Read: times |
#95882 - Jump Table in C Responding to: ???'s previous message |
See Keil for ideas:
http://www.keil.com/appnotes/docs/apnt_129.asp You just make a table of function pointers with the function names as the table entries. The syntax is a little strange the first time you do it. The implmentation by the compiler is excellent. Here are a couple of lines torn from my old code to show you an assignment method (as opposed to table): void (*focus)(); // Holds the addr of the current func to exec. focus = MyFunc; // Where somewhere I have a void MyFunc(void). (*focus)(); // Executing the function in focus var. Once you get that going, you can make a table of the MyFunc's. If it gives you the willy's, go with a switch statement. GB |
Topic | Author | Date |
Coding a Jmp table in C | 01/01/70 00:00 | |
Jmp Tables in C | 01/01/70 00:00 | |
you do not | 01/01/70 00:00 | |
Call table? | 01/01/70 00:00 | |
Of course not! | 01/01/70 00:00 | |
use jmp@a+dptr | 01/01/70 00:00 | |
jmp table not in C | 01/01/70 00:00 | |
Wrong ends of sticks? | 01/01/70 00:00 | |
You do not control the Compiler Output | 01/01/70 00:00 | |
You can not have your cake and eat it to | 01/01/70 00:00 | |
Jump Table in C | 01/01/70 00:00 | |
Call Table? (again) | 01/01/70 00:00 | |
Call Table? (again) | 01/01/70 00:00 | |
I never did use function pointers | 01/01/70 00:00 | |
No pain, no gain. | 01/01/70 00:00 | |
the overlaying | 01/01/70 00:00 | |
There can be a gain. | 01/01/70 00:00 | |
My 2 cents worth | 01/01/70 00:00 | |
Incorrect | 01/01/70 00:00 | |
As Matter of Fact....![]() | 01/01/70 00:00 |