Hi, i have a problem in calling 54x DSPLIB functions from assembly functions. I want to know that how to call C functions from Assembly module without main() in the C function. regards atanu ---- ATANU GUCHHAIT _/_/_/_/ _/_/_/_/_/ _/_/_/_/ _/ _/ _/ _/ Tel: +91-80-2282715 _/ _/ _/ _/_/_/_/ _/ +91-80-2263399 Ext. 245 _/ _/ _/ _/ _/ _/ 235 _/_/_/_/ _/_/_/_/_/ _/_/_/_/ _/ 312 Email: Centre for Development of Telematics 71/1, Sneha Complex, Miller Road, Bangalore - 560052, INDIA. ---- |
|
How to call c function
Started by ●January 3, 2001
Reply by ●January 6, 20012001-01-06
hi there... i think the main problem when interfacing c and assembly is the environment...when we make a program with c and link them all with rts.lib then boot.obj (which is in the rts.lib) will create the c environment. So ,one of the environment is the CPL bit from ST1 . You can read the full explanation in CPU and Peripherals Vol 1. Before you can jump from asm environment to c environment you must set CPL bit and you must reset back the CPL bit when you want go back to asm environment. One must be consider, that you must follow the C calling convention (read Optimizing C Compiler book) and put the first argument in ACC and put the remain in the stack in the reverse order... i hope this will help you... On Wed, 3 Jan 2001, Atanu Guchhait wrote: > Hi, > i have a problem in calling 54x DSPLIB functions from assembly > functions. I want to know that how to call C functions from Assembly > module without main() in the C function. > regards > atanu > > ---- > ATANU GUCHHAIT _/_/_/_/ _/_/_/_/_/ _/_/_/_/ > _/ _/ _/ _/ > Tel: +91-80-2282715 _/ _/ _/ _/_/_/_/ _/ > +91-80-2263399 Ext. 245 _/ _/ _/ _/ _/ _/ > 235 _/_/_/_/ _/_/_/_/_/ _/_/_/_/ _/ > 312 > Email: > Centre for Development of Telematics > 71/1, Sneha Complex, > Miller Road, Bangalore - 560052, INDIA. > ---- > To Join: Send an email to > > To Post: Send an email to > > To Leave: Send an email to > > Archives: http://www.egroups.com/group/c54x > > Other Groups: http://www.dsprelated.com |
Reply by ●January 8, 20012001-01-08
On Wed, 3 Jan 2001 17:57:21 +0500 (GMT+0500), you wrote: >Hi, >i have a problem in calling 54x DSPLIB functions from assembly >functions. I want to know that how to call C functions from Assembly >module without main() in the C function. >regards >atanu > The details on interfacing 'C' and ASM can be found in the TI reference docs, but here are a couple of things to remember. Set the CPL flag to 1 before calling the 'C' routine, and back to 0 when you return (unless you want it left set to 1). 'C' function names all start with an _ as I am sure you are aware. If you are doing far calls you need to take this into account, it changes the position of the variables on the stack by 1 because it also stores the XPC value for the return. Even with the docs, I always seem to end up figuring out the stack by trial and error using the debugger :( Brian ----------------- Brian C. Lane Programmer www.shinemicro.com RF & Microcontroller Design |
Reply by ●January 9, 20012001-01-09
On Tue, 9 Jan 2001 09:24:13 +0500 (GMT+0500), you wrote: >Thanks Brian for ur reply. But thing is that if u compile a c-function >with out main in ccs and then try to link with assembly language with a >proper .cmd file, it gives the warning that c_int00 is not >initialized. Morover the mapped file does not contain proper Ah, I see. You want 'c' code without main. Well, that's possible but not advised. The 'c' code expects memory to be setup for it by the c_int00 routine (which is found in the rts.lib library). I'd just put in a main() function, it will save you alot of trouble in the long run. But if you really want to avoid this, you can tell the 'c' compiler to generate and assembly listing from your 'c' code and then insert it into your project instead. Also, looking at the source of the rts.lib can be useful. I've actually modified mine somewhat to work better with expanded memory addresses. Brian ----------------- Brian C. Lane Programmer www.shinemicro.com RF & Microcontroller Design |