AnsweredAssumed Answered

trouble using a C variable in assembly

Question asked by san.gr on Jul 13, 2011
Latest reply on Aug 12, 2011 by san.gr

Hello everybody,

 

I am working on a project using an ADSP-BF533 and I need to pass a C++ variable in assembly.

 

More specifically, i am performing a ram physical integrity check and i want to move the stack pointer to a temporary location. I have declared a global structure with several attributes called "RamAttributes" and one of those attributes is a uint8 array "RamAttributes.stackTemp[10]".

 

So I want to move the stack pointer to the reserved memory &RamAttributes.stackTemp[9]. The reason i want the 10th position of the array is because the stack is filling backwards, ie from highest to lowest memory cell. Isn't that correct?

 

This is how I am doing it:

 

asm (".EXTERN _RamAttributes.stackTemp;");

asm (".type _RamAttributes.stackTemp,STT_OBJECT;");

 

asm ("P4.H=hi(_RamAttributes.stackTemp[9]);");

asm ("P4.L=lo(_RamAttributes.stackTemp[9]);");

 

asm ("R5 = [SP];");

asm ("[P4] = R5;");

 

asm ("R7.H=hi(_RamAttributes.stackTemp[9]);");

asm ("R7.L=0;");

asm ("SP = R7;");


When I try to compile I get the following error:

 

[Error ea5004] "C:\DOCUME~1\f20410\LOCALS~1\Temp\acc02d061d0000\acc02d061d0001.s":93 Syntax Error in :

P4.H=hi(_RamAttributes.stackTemp[9]);

syntax error is at or near text '['. Attempting error recovery by ignoring text until the ';'

 

I get this error for each reference of _RamAttributes.stackTemp[9]. If I remove the [9] then it compiles with no errors (I don't know if it runs on target yet).

 

Can I use a C declared array in assembly?  How?

Outcomes