This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Writing asm library and run from C

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!.

Parents
  • 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'?

Reply
  • 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'?

Children