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

same constant in assembler and C

I have a product where most is in C, but for speed reasons abt 2% is in assembler. A few constants are thus defined in 2 places

<constants.h>
#define VALUE 5

<constants.inc>
VALUE EQU 5

This is a maintenance nightmare, is there a method to make a change of the value in one place suffice.

Parents
  • Some later versions of the assembler can accept 'C' macros; eg, from Chapter 5 of the Macro Assembler and Utilities User's Guide 07.2000,

    "The Ax51 macro assembler has a standard C macro preprocessor that is almost identical with the macro preprocessors in the Cx51 compiler. This allows you to use common header files with constant definitions that can be used in assembler and C source files. The Ax51 macro assembler accepts also the special function register directives from the Cx51 compiler. Therefore you may use the same SFR register definition files for both assembler and C source files."

    Failing that, could you get a standalone 'C' preprocessor (or maybe some other text-processing utility) to convert your 'C' header into an A51-compatible format?
    (A previous Client used this approach to create assembler source & linker control files on their UNIX system).

Reply
  • Some later versions of the assembler can accept 'C' macros; eg, from Chapter 5 of the Macro Assembler and Utilities User's Guide 07.2000,

    "The Ax51 macro assembler has a standard C macro preprocessor that is almost identical with the macro preprocessors in the Cx51 compiler. This allows you to use common header files with constant definitions that can be used in assembler and C source files. The Ax51 macro assembler accepts also the special function register directives from the Cx51 compiler. Therefore you may use the same SFR register definition files for both assembler and C source files."

    Failing that, could you get a standalone 'C' preprocessor (or maybe some other text-processing utility) to convert your 'C' header into an A51-compatible format?
    (A previous Client used this approach to create assembler source & linker control files on their UNIX system).

Children