Keil Logo

C51: INDIRECTLY CALLED REENTRANT FUNCTIONS


Information in this article applies to:

  • C51 All Version
  • Cx51 All Version

QUESTION

I have problems passing lots of parameters to indirectly called functions. I tried to use the reentrant attribute but I could not make it work. Can you give me an example?

ANSWER

The example below shows the correct definition for reentrant functions that are called via function pointers. Both the function pointer and the function itself must contain the reentrant attribute. In addition, you must setup the reentrant stack pointer in the startup code (STARTUP.A51).

long* (*indirect_func) (long l, long* lp, int i) reentrant;

long* func (long l, long* lp, int i) reentrant {
  lp += i;              // just for demonstration
  *lp = l;
  return (lp);
}

long xdata larray[100];
long *lp;

void main (void)  {
  indirect_func = func;

  lp = indirect_func (500000L, larray, 5);
  while (1);
}

MORE INFORMATION

  • Refer to Data Overlaying in the BL51 User's Guide.
  • Refer to Application Note 129: Function Pointers in C51 for a complete discussion of all the ramifications of using function pointers with the C51 compiler.

SEE ALSO

Last Reviewed: Monday, July 18, 2005


Did this article provide the answer you needed?
 
Yes
No
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.