This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

including assembler file into C project

Hi all,
I have to include an ASM file into my C project, this ASM file cannot be modified since it is also a part of another project using this same file.

the ASM file is asm_inc.h and contains only some defines :

FW_VERSION EQU 0
FW_SUB_VERSION EQU 9
HW_VERSION EQU 1

I need to use these defines into a C table, defined as follow :

unsigned char code identity[] = {
FW_VERSION,FW_SUB_VERSION,HW_VERSION };

The problem is that I cannot see these defines from my C file :

error C202: 'FW_VERSION': undefined identifier
error C202: 'FW_SUB_VERSION': undefined identifier
error C202: 'HW_VERSION': undefined identifier

I've tried to include this asm file directly into my C file with no success

How can I include this ASM definitions into my C file ?

thanks to all
J

Parents
  • EQU is not part of the 'C' programming language (nor even Keil's extensions) so there is no way you can use this in a 'C' source file!

    "I need to use these defines into a C table, defined as follow:"

    unsigned char code identity[] = {
    FW_VERSION,FW_SUB_VERSION,HW_VERSION };
    You don't actually need to do that in 'C', do you?

    Why not just create your version information table in assembler, and let 'C' refer to it:
    extern char code identity[];
    You will, of course, need a corresponding PUBLIC declaration in your assembler...

Reply
  • EQU is not part of the 'C' programming language (nor even Keil's extensions) so there is no way you can use this in a 'C' source file!

    "I need to use these defines into a C table, defined as follow:"

    unsigned char code identity[] = {
    FW_VERSION,FW_SUB_VERSION,HW_VERSION };
    You don't actually need to do that in 'C', do you?

    Why not just create your version information table in assembler, and let 'C' refer to it:
    extern char code identity[];
    You will, of course, need a corresponding PUBLIC declaration in your assembler...

Children
  • While the C51 compiler cannot handle assembly language EQUates, the Ax51 assembler can handle C preprocessor #defines. Try:

    #define FW_VERSION 0
    #define FW_SUB_VERSION 9
    #define HW_VERSION EQU 1

    I'd declare the information in C with a struct rather than an array.

    typedef struct
        {
        U8 firmwareVersion;
        U8 firmwareSubVersion;
        U8 hardwareVersion;
        } VersionInfo;
    
    extern VersionInfo versionInfo;
    

    Define the actual table in a .c or .a51 file as you prefer.

  • "Define the actual table in a .c or .a51 file as you prefer."

    If you need to fix this table at a certain address, it will be easier to use .a51.