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

c89c51f120

hi,
i am working on silab's 89c51F120,
can i insert
assembly code in between the c code??
now i am writing the assembly code in a file with
A51 extension and ading it to the project and then calling those function in c program. can i directly insert wherever i want in c code??

  • "now i am writing the assembly code in a file with A51 extension and ading it to the project and then calling those function in c"

    That is by far the best way to do it. There is no reason to change.

    You can put inline assembler in your C51 source, but there are several reasons not to do it - so don't!

  • and then calling those function in c program. can i directly insert wherever i want in c code??

    I read this as follows "can I insert calls to assembler routines anywhere in a C program"
    If that is your question the answer is YES with one caveat (that apply to C functions as well) do not call them from both main and interrupts.

    That is simple, the one thing some forget relates to the opposite: when calling a C function from assembler you MUST assume EACH AND EVERY register (and some SFRs e.g PSW, ACC, DPH, b) will be destroyed. "testing" what is affected is the road to disater, there is no guarantee, WHATSOEVER, that it will be the same after next compile.

    Erik