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

Call C function (that calls another C function) from assembly code

Hi all,
I want to call a C function (for example: func1() ) from my old assembly code. The problem is that if func1() calls another C function( func2() ), what will happen? How does the compiler pass parameters to the second function? If it also passes through R1-R7, does it destroy the parameters of func1()?
Thanks for reading this topic.

Parents
  • "The problem is that if func1() calls another C function( func2() )"

    That is entirely irrelevant!

    The C51 calling convention defines how to call a function. It is the same for every function - that's the whole point of a calling convention.

    "If it also passes through R1-R7, does it destroy the parameters of func1()?"

    It will ensure that it does not destroy anything that it'll need again!

    Note that your assembler code must assume that the C51 function call will destroy all registers.

    You have read the chapter in the Manual on interfacing C51 and Assembler, haven't you?!

Reply
  • "The problem is that if func1() calls another C function( func2() )"

    That is entirely irrelevant!

    The C51 calling convention defines how to call a function. It is the same for every function - that's the whole point of a calling convention.

    "If it also passes through R1-R7, does it destroy the parameters of func1()?"

    It will ensure that it does not destroy anything that it'll need again!

    Note that your assembler code must assume that the C51 function call will destroy all registers.

    You have read the chapter in the Manual on interfacing C51 and Assembler, haven't you?!

Children