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.

  • 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).

  • My software is new (rev6.xx), but my boos are old (.97 .98). Are the manuals avilable on-line, I have hunted now for a good while and not found them.

    Erik

  • If you're using uVision, go to the 'Books' tab in the Project window.

    The PDF files are all on the free CD, and get installed into the Keil\C51\Hlp folder on installation:

    C51.pdf - C51 manual
    A51.pdf - A51 manual
    GS51.pdf - Getting Started guide (the nearest there is to a uVision Manual).