DSPRelated.com
Forums

asm to a C callable function

Started by Unknown July 13, 2001


Hi,

I needed to convert an asm to a C callable function. So I though the list might
be
interested in a template that gets the passed-in parameters off the stack and
provide a return value at the end of the routine.

This is for VisualDSP++ 2.0 (ADSP-218x)

c prototype: int foo(int p, int q);

ASM of foo:

foo.asm ===========================================
.SECTION/CODE program;
.GLOBAL _foo;
_foo:
// Copy passed-in parameters off stack
M5=1; // set increment
I6=I4; // copy stack pointer
MODIFY(I6+=M5);
AX0=DM(I6+=M5); // get "P"
AX1=DM(I6+=M5); // get "Q"

// your asm code goes here // Follow compiler reg
// usage conventions

end_foo:
// Function return-value set here
AX1 = SR0; // return in AX1
RTS;

._foo.end:
.size (_foo,._foo.end-_foo);
===================================================