accessing c macros in different asm file

Hello all,
I am trying to use the c macros in asm file. I have 2 different files( sample.c and macro.asm.In sample.c I have defines a macro #define NUM 5 and now I want to use this NUM in asm file.What should I do? Also tell me the way of using the asm file macro in c.
Anand.

Comments

  • : Hello all,
    : I am trying to use the c macros in asm file. I have 2 different files( sample.c and macro.asm.In sample.c I have defines a macro #define NUM 5 and now I want to use this NUM in asm file.What should I do? Also tell me the way of using the asm file macro in c.
    : Anand.
    :
    :
    You can't. However there exist tools to convert assembler preprocessing directives to CPP preprocessing directives and vice-versa at least for some assemblers. Borland has two tools cpp2ash and ash2cpp or something to that effect that will convert between CPP preprocessor directives and TASM's preprocessor directives. A somewhat extreme solution is simply to use CPP for both as CPP is separate from C/C++. Here's a quick example of what it might look like...
    [code]
    #define NUM 5

    mov ax, NUM
    [/code]

    the run cpp on the .asm file and you'll get another file (with Borland's cpp it will have a .i extension) rename this to a .asm file and run the assembler on it. You could easily make a shell script/batch file to automate this process. The resulting .i file using Borland's cpp with option -P- would be...

    mov ax, 5

    "We can't do nothing and think someone else will make it right."
    -Kyoto Now, Bad Religion

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion