Hi all, How can I call assembly routine (or .asm file) from C. I am using Code Composure Studio V4.10 and C31. Thanks in advance. Kalpesh Chauhan (Sr.Engineer, R&D) -------------------------- Hirel Electronics Ltd, Gandhinagar, India |
|
Calling Assembly from C
Started by ●August 6, 2001
Reply by ●August 9, 20012001-08-09
Hello Kalpesh Interruptable Function? ----------------------- First off I am going to assume that this is a normal function that is not going to be within an interrupt routine. It should be pretty obvious that if this was an interrupt routine you would want to save and restore everything that gets used. Compiler conventions -------------------- The next thing I would do is look at the C-compilers register use and preservation conventions found on PG 4-11 of SPRU034G TMS320C3x/4x Optomizing C-Compiler. When the compiler is used to generate a function it assumes certain rules will be used to pass arguments to and from the function. In addition, the compiler will assume that some registers can be used by the called function without corrupting the callee's environment. Knowing this allows you to use these registers for fast temporary data. Then, I would try compiling my function as a C function, but I would tell the compiler to generate and not erase the intermediate ASM file (CL30 -k option). You can then look at this file and see how the compiler interprets your code when various compile options are used. Very very informative! NOTE: Take special notice of how the compiler generates code for large/small and register passing models. Not only will this code be different, but the libraries you link in will be different. The most efficient is the small model with register passing. This is especialy important for TMS320VC33 users since all of the onchip SRAM and peripherals fit into one data page greatly improving peformance. Using the Debugger to Debug --------------------------- You may or may not have your function to the point where it is doing something usefull, but when you do get to the point where you can step over the function, the debuggers highlighting feature can now be used to tell you wether or not you have violated some rules. Basicaly this is a fast indicator that tells you when a register has been corrupted or some other silly thing that is sure to not work. Context Pointer AR3 ------------------- When the compiler generates a function it uses AR3 to point to the functions local stack or heap which holds the functions temporary variables (notice how SP is bumped up in size). AR3 is also important to the HLL debugger since this pointer to the local variables can now be used to access and display the contents of those variables. And, since the real stackpointer register SP has been bumped up in size, you are safe to take an interrupt without having the interrupt (which also uses the stack) eating up the local variable data. Must you use AR3 and the stack in this fashion? NO, YOU DONT! And in some cases this can make your function run a fair bit faster and use a lot less memory. However, you wont be able to debug the inner workings of the function in the same way as the HLL debugger. Is this a problem? I doubt that too. Hope this helps, Keith Larson PS: There will be a new service pack to CC coming out in the next few weeks, so keep an eye out for it. Ill try to remember to send an email to this group when it does. ------------------------ At 09:57 AM 8/6/01 +0530, you wrote: >Hi all, > >How can I call assembly routine (or .asm file) from C. I am using Code Composure >Studio V4.10 and C31. > >Thanks in advance. > >Kalpesh Chauhan >(Sr.Engineer, R&D) >-------------------------- >Hirel Electronics Ltd, Gandhinagar, India > ____________________________________ >Note: If you do a simple "reply" with your email client, only the author of this message will receive your answer. You need to do a "reply all" if you want your answer to be distributed to the entire group. > >_____________________________________ >About this discussion group: > >To Join: Send an email to > >To Post: Send an email to > >To Leave: Send an email to > >Archives: http://groups.yahoo.com/group/c3x > >More Groups: http://www.dsprelated.com >">http://docs.yahoo.com/info/terms/ > |