DSPRelated.com
Forums

Reading variables from asm into C.

Started by aova...@hotmail.com March 22, 2006
Hi everybody,
I am using the ADSP-21262 processor and VisualDSP++ 4.0.
I have a variable (circular buffer) defined in asm that acquired an audio input signal and I would like to read that variable in a C function to perform a FFT.
Does anybody know how to read variables from asm into C ?
Thanks
When naming the variable in assembly language, make sure the name
starts with an _ Then make a c prototype for the variable (without
the _ ), and call it just like any other c variable (don't use an _ ).

For example

in assembly
.VAR _My_Var

in C

extern int My_Var.

I haven't done this for a long time, so I'm not guaranteeing that it
works.

I usually define the circular buffer in C, and pass the address and
size to the assembly language routine by calling an assembly language
function.

example

int MyBuf[50];
void AsmInit(int *Buf, int size);
--- In a..., aova2@... wrote:
>
> Hi everybody,
> I am using the ADSP-21262 processor and VisualDSP++ 4.0.
> I have a variable (circular buffer) defined in asm that acquired an
audio input signal and I would like to read that variable in a C
function to perform a FFT.
> Does anybody know how to read variables from asm into C ?
> Thanks
>
a...@hotmail.com schrieb:
> Hi everybody,
> I am using the ADSP-21262 processor and VisualDSP++ 4.0.
I use ADSP-21161, that should make no difference here...

> I have a variable (circular buffer) defined in asm that acquired an audio input signal and I would like to read that variable in a C function to perform a FFT.
> Does anybody know how to read variables from asm into C ?

In asm declare the variable as
.var _buffer[BUFFERLENGTH];
(with underscore!)

and make it globally visible with
.global _buffer;

In C declare it as external with
extern float buffer[BUFFERLENGTH];
(without underscore)

In asm you will have to access the variable as "_buffer", in C as "buffer".

You would get the same with defining in C
float buffer[BUFFERLENGTH];

and declare in asm
.extern _buffer;

Generally, C symbols are visible in asm with underscore prepended, to
make asm symbols visible in C, they must have the underscore in front.
This holds true for function names as well.

Regards
Norbert

--
Dr. Norbert Langermann - Softwareentwickler
RADIODATA Kommunikationstechnik GmbH
n...@radiodata.biz
OpenPGP-Key: 0x51431418