We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi, I work on Keil uVison V2.38, and i would to know how can i give an adress to a function ; which instruction can help me to fix the adress of functions or variables. If you have some docs or exemples, please send me : jm.moulinier@synergie-cad.fr Thanks !!
I usually recommend that people consider making a vector table, rather than locating the actual function at a fixed address. (Fixing the address of the functions also fixes their maximum size, and makes it harder for the linker to do its job.) It's similar to the way the interrupt vector table in the hardware works. Just declare a table of function pointers; locate that table at a well-known, fixed address (using the linker, since you'll probably want to use an initializer to specify the function addresses). The clients look up the address of function N in the table and call it. It would look something like:
typedef void (*Vector)(void); typedef enum { VecA, VecB, VecC, NumVectors } VectorApi; const Vector code myTable[NumVectors] = { // initializer means you can't use _at_ Func1, Func2, Func3 } ... // client code myTable[VecA]();