Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.
I don't know the details of the compiler that you are using. However, in various C compiler it's as follows:
1. Declare a function/procedure/label in the asm file that have a global linkage property, i.e. something like:
Code:
.gobal my_function
my_function:
; your function asm routines
2. You can call this function from your C code with:
Code:
my_function();
3. Some notes:
a. I don't know the specifics of your compiler, so please read its documentations.
b. The linkers need the asm file to be compiled into object code to be able to be linked.
c. The ".global" keyword in the code in point 1 is only a hint. Your compiler might have different syntax
C macros provide a convenient way to insert extended inline assembly code into your C source code. Macros demand extra care because they expand in a single logical line. Follow these rules to create trouble-free macros:
Enclose the __asm block in braces ('{}').
Put the __asm keyword in front of each assembly instruction.
Use only traditional C comment delimiters ('/*') and ('*/'). Assembly-style comment delimiters (';') and single-line C comment delimiters ('//') are not possible.
For example:
The __asm keywords (highlighted in red) seem superfluous. However, they are required because C macros are expanded in a single line.
The preprocessor's handling of '#' within macro definitions that begin with the __asm keyword is relaxed (since # is used for immediate values in assembly language). In standard C, an assembly immediate value like #0x10 would cause an error in the preprocessor phase because it violates the C preprocessor rules.
The following example demonstrates how to define and use an extended inline assembly block in a macro.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.