Carlos Hidalgo

Using array of functions

Discussion created by Carlos Hidalgo on Nov 28, 2006
Latest reply on Nov 28, 2006 by Carlos Hidalgo
I've created a function pointer array in FLASH as follows:
typedef void (* FunctionType)(void);
const FunctionType jumptable[64] = {
  mstate_00,  mstate_01,  mstate_02, ...  mstate_63 };  // states 00-63
I'm calling the funcition as follows:
and the compiler is generating:
 4349:     (*jumptable[mstate])(); // got to the appropriate subroutine
 01c0 be00     [3]             LDX   mstate
 01c2 58       [1]             LSLX 
 01c3 8c       [1]             CLRH 
 01c4 e600     [3]             LDA   @jumptable,X
 01c6 ee01     [3]             LDX   @jumptable:1,X
 01c8 87       [2]             PSHA 
 01c9 8a       [2]             PULH 
 01ca fd       [4]             JSR   ,X
This causes a link error because it's generating the indexed 8-bit offset loads (e600 & ee00) rather than the indexed 16-bit offset loads (d60000de0000) I need.  How do I convince the compiler it must treat jumptable as a "far" entity?  I've tried adding the "far" qualifier without success.