Need help with GNU assembly

Patil, Kiran kiran.patil at intel.com
Thu Jun 14 21:39:43 UTC 2007


Hi All,

 

I am trying to use GNU assembly. I am trying simple thing such as ,
moving content of memory location into general purpose register (ax).

 

I have following code :

 

struct context {

 

            unsigned long mask[8];

} CONTEXT;

 

int main()

{

            CONTEXT sr;

            sr.mask[5] = 0x8FED;

 

            __asm ( "movw %0, %ax" : : "m" (*(unsigned
short*)sr.mask[5]) );

            return 0;

}

 

Compiler complains with error "bad substitution directive in asm
instruction".

 

I tried changing the code something like this :

 

__asm ( "movw %0, %ax" : : "m" (*(unsigned short*)sr.mask+5) );

 

Still error is same, then I tried following:

 

            Unsigned short* ptemp = &sr.mask[5];

            __asm ( "movw %0, %ax" : : "m" (*(unsigned short*)ptemp) );

But still no luck, compiler reported same error as mentioned above

 

Any help is appreciated. Please let me know where I am mistake.

 

Thanks,

-- Kiran P.



More information about the freebsd-questions mailing list