Sign in

username:

password:



Not a member?

Search c3x



Search tips

Subscribe to c3x



c3x by Keywords

Boot | C31 | TMS320VC33 | VC33

Sponsor

Industry's highest performing at the lowest power DSPs now as low as $5.00*
Start development today!
*volume pricing for 10ku

Discussion Groups

See Also

Embedded SystemsFPGAElectronics

Discussion Groups | TMS320C3x | Calling Assembly from C

Technical discussions about the TI C3x DSPs (including the C31, C32 and C33 DSPs).

  

Post a new Thread

Calling Assembly from C - design - Aug 6 4:27:00 2001

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




______________________________
New Code Sharing Section now Live on DSPRelated.com. Learn about the Reward Program for Contributors here.



(You need to be a member of c3x -- send a blank email to c3x-subscribe@yahoogroups.com )

Re: Calling Assembly from C - Keith E. Larson - Aug 9 18:38:00 2001

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
>
____________________________________



______________________________
New Code Sharing Section now Live on DSPRelated.com. Learn about the Reward Program for Contributors here.



(You need to be a member of c3x -- send a blank email to c3x-subscribe@yahoogroups.com )