Sign in

username:

password:



Not a member?

Search c54x



Search tips

Subscribe to c54x



c54x by Keywords

5409 | 5416 | AD5 | ADC | BIOS | Boot | Booting | Bootloader | C540 | C5402 | C5409 | C5416 | CCS | Codec | DMA | Dmad | DSK | DSKPlus | Dsplib | EVM | FFT | FIR | Flash | GPIO | HPI | Initialization | Interrupt | JTAG | LOG_printf | MCBSP | RFFT | RTDX | Sampling | STLM | UART | VC540

Discussion Groups

Discussion Groups | TMS320C54x | Re: Help in Assembly coding in 5416

Technical discussions about the TI C54x DSPs (including the c5401, c5402, c5402a, c5404, c5407, c5409, c5409a, c5410, c5410a, c5416, c5420, c5421, c5441, c549, c5470 and c5471).

  

Post a new Thread

Re: Help in Assembly coding in 5416 - Author Unknown - Jan 3 12:56:00 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:





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

Help in Assembly coding in 5416 - Ulrich Prakash - Jan 4 5:25:00 2003

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>http://voip.hcltech.com
*********************************************************
"There is one corner of the universe you can be
certain of improving, and that's your own self"
*********************************************************





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

Re: Help in Assembly coding in 5416 - Jeff Brower - Jan 5 17:30:00 2003

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>http://voip.hcltech.com
> *********************************************************
> "There is one corner of the universe you can be
> certain of improving, and that's your own self"
> *********************************************************





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