Hello! I have a some trouble. I'm writing some library on ASM. This library contane some function takes as a parameter two doubel or float (in Cx51, this types identicly) variable. If i call this function from ASM i manualy place this variable, example, in R0 R1 R2 R3 - first var. and R4 R5 R6 R7 - second var, but if i definate this function in C
double func(double var1, double var2)
, this mean next: on call this function first variable by compiler will be placed in R4 - R7 registers, but second variable will be placed in a place determined by the compiler. See http://www.keil.com/support/docs/2314.htm. How i can write similar function in my library, which can be called from C source(with out more operation with vars). Example :
double var3 = my_func(double var1,double var 2)
. Thank for help!.
write a skeleton of your asm function in C and use the generated assembler s a template. REMEMBER, compile the skeleton w/o optimization.
void my_func(double var1,double var2) { double loc1; double loc2; loc1 = var1; loc2 = var2; }
Erik
Surely, the fact that it's a library is irrelevant - you just need to ensure that your functions follow the C51 calling convention.
Read the section titled "Interfacing 'C' to Assembler" in the C51 Manual.
But why do you want to do this in assembler anyhow? Surely floating point would be far better handled in 'C'?
The process is illustrated here: www.8052.com/.../149030
Thanks guys for your help! I try to use you reply's.