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

calling C from Assembly

I am trying to learn to call some C floating point routines from Assembly.
I am quite proficient in writing Assembly programs which | have done commercially for many years.
I have read the <http://www.keil.com/support/docs/697.htm> page but can make no sense of it
Basically where is what to be done?
For example what does "You can then use the src file as a template to...."
And "....you must also include the EXTRN directive for the function, eg: EXTRN CODE (_foo)"
I include it where? Will the final project be an assembly project or a C project?
I have written my own Assy routines for +-x/ in Floating point but now need some Sin/Cos/log functions. Hence the need for C. Which I hate.
I found that it is not possible to use the #pragma src is directed and I have to assemble the file twice.
Can some kind person please help by, say, pointing to some page where I can begin to understand Keil C language conventions. The Keil Documents do not give a place where I can find the start of a thread to unravel. Every explanation points to another explanation in another place. I do know C/C++ but not segment controls much.
Thanks for the help

Parents
  • "what does 'You can then use the src file as a template to'"

    They mean that it gives you an example showing how a call to a 'C' function is done in assembly - so you can modify and/or expand that example to suit you particular requirements to do whatever it is that you want to do in your application!

    "....you must also include the EXTRN directive for the function, eg: EXTRN CODE (_foo)"

    I thought you said you were a proficient assembly programmer?
    EXTRN is a standard assembler directive - you use it in exactly the same way that you would in any other assembly sourcefile.
    http://www.keil.com/support/man/docs/a51/a51_st_extrn.htm

    "Will the final project be an assembly project or a C project?"

    The tools rely on finding a 'C' main() function to tell them to include all the necessary support for 'C' - including floating point.
    Therefore, it is probably easiest to have your application start from a 'C' main() function.

    You can do all necessary support for 'C' "manually" - and there are plenty of discussion threads and knowledgebase articles about that - but it seems to me like deliberately making things difficult for yourself!

    "...C. Which I hate"

    Why do you hate it?
    Doesn't this very question give you a very good reason to embrace it?

Reply
  • "what does 'You can then use the src file as a template to'"

    They mean that it gives you an example showing how a call to a 'C' function is done in assembly - so you can modify and/or expand that example to suit you particular requirements to do whatever it is that you want to do in your application!

    "....you must also include the EXTRN directive for the function, eg: EXTRN CODE (_foo)"

    I thought you said you were a proficient assembly programmer?
    EXTRN is a standard assembler directive - you use it in exactly the same way that you would in any other assembly sourcefile.
    http://www.keil.com/support/man/docs/a51/a51_st_extrn.htm

    "Will the final project be an assembly project or a C project?"

    The tools rely on finding a 'C' main() function to tell them to include all the necessary support for 'C' - including floating point.
    Therefore, it is probably easiest to have your application start from a 'C' main() function.

    You can do all necessary support for 'C' "manually" - and there are plenty of discussion threads and knowledgebase articles about that - but it seems to me like deliberately making things difficult for yourself!

    "...C. Which I hate"

    Why do you hate it?
    Doesn't this very question give you a very good reason to embrace it?

Children