Keil Logo

C51: Indirect Function Calls with Code Banking

Information in this article applies to:

  • C51 version 5.50 and later


I do an indirect call through a table of function pointers from bank 0 to a function in the same bank. The compiler generates a call to ?C?ICALL which is in the common area. The linker then seems to assume that the call must go through the bank switch jump table since we are now jumping from common to bank 0. My table of function pointers is located in the same bank as the calling and called functions.

Is there any way (other than modifying my source) of telling the linker that these calls can be made directly without going through the jump table?

I don't mind the speed hit, but I can't afford the 6-byte overhead in the common area on each function.


There is a simple way to avoid this kind of cross call in C51 V5.50 and later. The linker offers a directive called NOINDIRECTCALL. By default, the linker inserts inter-bank CALLs for indirectly called functions in code banking applications. If your application uses multiple pointers to functions and if you can ensure that these indirect calls never cross a code bank you may use the NOINDIRECTCALL (NOIC) linker directive.

Note that the NOINDIRECTCALL only works for function tables and not for function pointer references within a function.


Module in Common Area:

extern void id_call (void (* f) ());
extern void funca (void);
extern void funcb (void);
extern void funcc (void);

void (*f[])(void) = { funca, funcb };

void test (void)  {
  id_call (f[0]);
  id_call (f[1]);

// The following always generates an inter-bank table entry
  id_call (funcc);

Module in Code Bank:

void funca ()  {

void funcb ()  {

void funcc ()  {

void id_call (void (* f) ())  {
  f ();

By using the NOINDIRECTCALL linker directive, the intrabank table entries for funca and funcb are avoided.



Last Reviewed: Thursday, February 25, 2021

Did this article provide the answer you needed?
Not Sure
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.