Hi!
To speed up a routine in a C-project, I implemented a function which is called several times in assembler. At the moment it looks like the following:
void myop(unsigned char a, unsigned char b) { #pragma asm ..... #pragma endasm } myop(1, 2); myop(3, 4); ....
If I take a look at the debuger, the compiler always does a LJMP to execute the function. The assembler code in myop() is ~35 lines of code.
Is it possible to define myop as a macro that it gets completely inlined without doing LJMPs?
I am search for something like:
#define myop(a, b) (#pragma asm; .....; #pragma endasm)
Or maybe I can just include in from some external file?
Thanks for help in advance! Cheers Markus
If I take a look at the debuger, the compiler always does a LJMP to execute the function.
The type of call the compiler uses should depend on the memory model you selected.
... but I want to prevent any call. Just inline assembler. :)
Markus
In that cast, you'll probably have to use a macro and find a clever way to get the data to the macro (Note: It's probably a bad idea to access any processor registers in C. Using data memory locations would be safe).
Well, the C51 compiler can't even inline C functions ...
A standard C preprocessor can't generate preprocessor statements from a #define'd macro. So, your choices to repeat at each point of call would be manual #pragmas:
#pragma asm MyMacro() #pragma endasm
or, as you say, an separate file containing the pragmas and code with a #include inserted at the point of call:
#include "mymacro.i"