I have all of my software code made in 8051 assembler. The R0-R7 (Bank 0,1)registers, accumulator, and DPTR, are used in the most of my code, like a functions arguments. How could I do, to call a "C" subrutine and hold the integrity of my code? What is the best way, to preserve or separate, two parts of differents codes? Thank you.
1. Save integrity (context). 2. Call C "subrutine". 3. Restore integrity (context).
But first:
0. Please read the manual: http://www.keil.com/support/man/docs/c51/c51_ap_ctoasm.htm
Note that you can't just add an isolated 'C' file to an assembler project - 'C' requires a certain amount of initialisation & runtime support.
By far the easiest way to do this is to ensure that your program's main() is in 'C', and have that call your assembler entry point.
That could be as simple as:
void main( void ) { asm_main(); }
Thank you Dan and Andy. What do you mean (context)
{ push_registers(); // 1. function_in_c(); // 2. pop_registers(); // 3. }