hello,
I'm trying to write some inline assembler code that accesses the attributes of a structure that is passed to it. A previous post ( http://e2e.ti.com/support/development_tools/compiler/f/343/p/100304/773310.aspx#773310 ) said you could just add an '_' to the front of the type, but I've had no luck in getting this working. I've also looked at the generated .asm file and still couldn't see anything that helped.
In my simple example below I want to use +XAR4[_MyStruct.b] instead of +XAR4[1]. I don’t want to hard code the attribute's offset in the assembler, I want to be able to get the attributes offset from the structure. Can somebody please show me how to achieve this.
typedef struct MyStruct
{
int a;
int b;
int r;
}MyStruct;
void Add (MyStruct * Ptr)
{
#if 0
Ptr->r = Ptr->a + Ptr->b;
#else
asm(
" MOV AL, *+XAR4[0]\n" //*+XAR4[_MyStruct.a]
" ADD AL, *+XAR4[1]\n" //*+XAR4[_MyStruct.b]
" MOV *+XAR4[2], AL\n" //*+XAR4[_MyStruct.r]
);
#endif
}
void main(void)
{
MyStruct x;
x.a = 4;
x.b = 2;
Add(&x);
}
My final goal is to write a inline 2p2z controller that is called from "C" code. It needs to be assembler because there aren't the required intrinsic commands to do this. Also to avoid the calling overhead it has to be inline. And to enable me to debug the rest of my code I don’t want to turn on full program level optimization.
cheers
Chris