Howdy, Stranger!

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

Categories

accessing c macros in different asm file

c_anandsc_anands Member Posts: 53
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

  • DariusDarius Member Posts: 1,666
    : 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

  • Andre YoungAndre Young USAMember Posts: 0

    ____ | http://forcoder.org | free ebooks and video tutorials about { Visual Basic PL/SQL R PHP Scratch Python MATLAB C Visual Basic .NET Java Objective-C JavaScript Assembly Ruby Go Perl Swift C# Delphi C++ Transact-SQL Lua Logo Lisp COBOL Crystal Apex F# Alice Dart Rust VBScript Bash Awk Erlang Clojure FoxPro Hack Prolog LabVIEW Scheme Ada SAS Kotlin Fortran Scala ABAP ML D Julia }

Sign In or Register to comment.