DSPRelated.com
Forums

Re: Help in Assembly coding in 5416

Started by Unknown January 3, 2003
Hello Ulrich,

Saturday, January 04, 2003, 8:25:14 AM, you wrote:

It would be a solution to declare func as
func(int *x, int *a, int *y);

Then you'll get &x in register A, and *sp(0) and *sp(1)
for &a and &y. Thus you'll gain full access to Y.

void p(int *a, int *b, int *c)
{
*c=*a+*b;
return;
}

and the corresponding Assembler code is

_p:
PSHM AR1
FRAME #-1
STLM A,AR2 ; |2|
STL A,*SP(0) ; |2|
MVDK *SP(3),*(AR1) ; |3|
LD *AR1,A ; |3|
MVDK *SP(4),*(AR1) ; |3|
ADD *AR2,A ; |3|
FRAME #1
STL A,*AR1 ; |3|
POPM AR1
RET
; return occurs

UP> I want to call an Assembly routine from C program like:
UP> main()
UP> {
UP> int A[3];
UP> int X[3];
UP> int Y[3];

UP> //store some values in arrays X, and A

UP> //call Assembly function(func) to do some calculations and find array Y
UP> from these 2 inputs

UP> Y = func(&X, &A); UP> } --
Best regards,
Michael Kapralov mailto:



Hi,

I have not done much assembly coding and hence I have the following doubt
while coding in Assembly with a C5416 DSP:

I want to call an Assembly routine from C program like:
main()
{
int A[3];
int X[3];
int Y[3];

//store some values in arrays X, and A

//call Assembly function(func) to do some calculations and find array Y
from these 2 inputs

Y = func(&X, &A); }

Doubt:
If I pass the arrays by Address,how do I read the parameters inside the
Assembly function func? and store in some address locations,so that they
can be fetched to calculate Y.
Also how do I return the ARRAY Y from the function func?

Any sample code,illustrations or suggestions may be very useful.

Thanks & regards,

**************************************************
M. ULRICH PRAKASH
Networking Technologies Lab,
HCL Technologies Ltd.,
184 N S K Salai,
Vadapalani, Chennai 600 026
Tel: 91 - 44 - 372 8366 x1136 Fax: 480 6640
Visit:: <http://voip.hcltech.com" target="_blank" rel="nofollow">http://voip.hcltech.com>http://voip.hcltech.com
*********************************************************
"There is one corner of the universe you can be
certain of improving, and that's your own self"
*********************************************************



Ulrich-

Michael Kapralov's answer is very good, all your details are there.

Trying to do Y = func(X, A) is sort of "MATLAB-like" and not easy in C54xx C/asm
coding. But if Y is always either X or A or some offset from them, say Y is
always
X+N, where N=3 in your example below, then the asm. function can return a
pointer
value in acc A and store the results at X+N. You can get it to work, but it
won't be
obvious to other people and you should put some "large, noticeable" comments in
there
to explain it.

Jeff Brower
DSP sw/hw engineer
Signalogic

> I have not done much assembly coding and hence I have the following doubt
> while coding in Assembly with a C5416 DSP:
>
> I want to call an Assembly routine from C program like:
> main()
> {
> int A[3];
> int X[3];
> int Y[3];
>
> //store some values in arrays X, and A
>
> //call Assembly function(func) to do some calculations and find array Y
> from these 2 inputs
>
> Y = func(&X, &A);
>
> }
>
> Doubt:
> If I pass the arrays by Address,how do I read the parameters inside the
> Assembly function func? and store in some address locations,so that they
> can be fetched to calculate Y.
> Also how do I return the ARRAY Y from the function func?
>
> Any sample code,illustrations or suggestions may be very useful.
>
> Thanks & regards,
>
> **************************************************
> M. ULRICH PRAKASH
> Networking Technologies Lab,
> HCL Technologies Ltd.,
> 184 N S K Salai,
> Vadapalani, Chennai 600 026
> Tel: 91 - 44 - 372 8366 x1136 Fax: 480 6640
> Visit:: <http://voip.hcltech.com" target="_blank" rel="nofollow">http://voip.hcltech.com>http://voip.hcltech.com
> *********************************************************
> "There is one corner of the universe you can be
> certain of improving, and that's your own self"
> *********************************************************