Can you provide a compilable sample?
In the provided one, f1 does not have a return type, Char is undefined, f3,f4 are used before being defined.
f2 is used as parameter name and as function name, I guess as hint that the function is passed as this parameter.
Functions are allocated banked, so I guess this is with the banked memory model, is this correct? Which compiler options, which compiler, which version,....
I'm a bit confused by "0x9856F000". The compiler is not using 4 bytes for pointers, is the code somehow also using longs for pointer values?
Anyhow, there is no issue if you keep the types clean. Especially for the S12, __far data and __far function pointers do not mix directly, they use a different byte ordering. So as long as the code is passing function pointers as function pointers (and __far function pointers as __far function pointers), there should be no issue. However if the code is using data pointers in between (I guess that is what the Char* as returned by f2 is), then you run into the byte ordering issues.
So try to return a function pointer type from f2. Also I would recommend to use typedef's for function pointers for readability.
Especially if you have function pointer types which return function pointers
.
typedef char (fX_t*)(void);typedef fX_t (fS_t*)(int);void f1(fS_t, int p, int j){ //body of the function.} fX_t f2(int i);
Daniel