DSPRelated.com
Forums

inline assembly

Started by haoyeshen May 11, 2005
I am trying to write a dsp sw to perform acoustic echo cancelling
function. To increase the code efficiency, I need to write part of my
code in assembly language. I am wondering how I could do so. The
biggest problem I have is that I don't know how to pass a variable
defined in C to a assembly function. Please help.


Hi Haoyeshen

Look at the manual "Targeting MC56F83xx/DSP5685x Controllers", also called:
"CodeWarrior(tm) Development Studio for
Motorola 56800/E Hybrid Controllers:
MC56F83xx/DSP5685x Family Targeting Manual"

I found it in my Metrowerks installation directory, not on the Freescale
website:
"C:\Program Files\Metrowerks\CW6\Help\PDF\Targeting_56800E.pdf"

These sections should be helpful:

Inline Assembly Language and Intrinsics
Calling Assembly Language Functions from C code

You might also want to look at this section in the same manual:
C for DSP56800E
Calling Conventions and Stack Frames

Rick Corey -----Original Message-----
From: motoroladsp@moto... [mailto:motoroladsp@moto...]On
Behalf Of haoyeshen
Sent: Wednesday, May 11, 2005 12:03 AM
To: motoroladsp@moto...
Subject: [motoroladsp] inline assembly I am trying to write a dsp sw to perform acoustic echo cancelling
function. To increase the code efficiency, I need to write part of my
code in assembly language. I am wondering how I could do so. The
biggest problem I have is that I don't know how to pass a variable
defined in C to a assembly function. Please help.


--- In motoroladsp@moto..., "haoyeshen" <haoyeshen@y...>
wrote:
> I am trying to write a dsp sw to perform acoustic echo cancelling
> function. To increase the code efficiency, I need to write part of
my
> code in assembly language. I am wondering how I could do so. The
> biggest problem I have is that I don't know how to pass a variable
> defined in C to a assembly function. Please help.

The easiest way to develop an assembly-only version of a primitive is
to first write the primitive in C. You can then see how your calling
program arranges arguments in core registers and the stack before
calling the primitive. (Simply go to mixed view in the debugger and
read what the code is doing before and after the jsr, or disassemble
the file.)

You can do the same for the primitive. Go to mixed mode in the
debugger (or disassembly) and see how the called routine unpacks the
arguments.

The final reference, as Rick Corey said earlier, is the targeting
manual.

One final warning: When it comes to DSP, often you will find that
setup and teardown of the DSP primitive costs more than the
processing contained in the primitive. In these cases the only
solution is to "in-line" the primitive in the calling code by moving
the assembly from the primitive to the calling code. This,
unfortunately, requires that the calling code be written in assembly
as well.