Hi, I have a project has both *.a51 and *.c source files. I wrote a macro in assembly code. Is is possible to use this maro in my c code? file: macro.a51 MACROTEST MACRO . MOV A,#0 . . ENDM END file: testmacro.c void Test(void) { . . MACROTEST . . } Thank you. Ovid.
No. And it would probably make little or no sense even if you could do it. The opposite direction works, though: you can use C #define's from inside an asm source file if you #include the respective header.
I have to fine tune a sub routine. 1. write this sub routine as macro -- so I can save some function call and function return instructions. 2. It is impossible to use inline assembly in a C macro. like this # define MACROTEST if(variable) \ { \ #pragma asm \ . \ . \ clr a \ . \ #pragma endasm \ }/ 3. I also have to use a preprocessor in the macro. But it seems illegal also. # define MACROTEST if(variable) \ { \ #ifdef GLA \ do A #else \ do B #endif \ } \ So, is there any good method to achieve what I need? thank you. Ovid.
C preprocessor commands can't be used inside the replacement text of a macro, right. So don't do that. It should be possible to do something like
#define MACROBODY clr a; djnz r7,wherever /* ... */ #pragma asm MACROBODY #endasm