Keil Logo

C51: Naming Conventions for Function Symbols


Information in this article applies to:

  • C51 Version 5.50a and later

QUESTION

I have problems passing parameters from a C file to an assembly function. I think the problem is with the declarations.

My assembly function receives a pointer as an argument. The C prototype I'm using is:

extern unsigned char Function (unsigned char xdata *);

The assembler code is:

public  Function
Function:
  MOV   A,R7
  .
  .
  .
  RET

When I build my project, the linker outputs the warning Unresolved External Symbol for Function in the C file. If I change the function prototype to have a void argument list and if I pass no parameters to Function, the program compiles and links without warnings.

What could be the problem?

ANSWER

The C51 compiler adds an underline character ('_') to the beginning of function names to indicate that all arguments are passed in registers. This is documented in the Cx51 User's Guide under Program Objects. If you add an underline character ('_') before the function name in the assembler source file your project will build as you expect.

MORE INFORMATION

SEE ALSO


Last Reviewed: Thursday, February 25, 2021


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.