Array references in inline assembler

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



What memory reference syntax is used to refer to the nth element of an array
in inline assembler?  For example, the following x86 example doesn't
assemble:

void test()
{
   unsigned _tmp[8];
   __asm__ (
      "movl %%edi, 12(%0)"	// generates movl %edi, 12(-40(%ebp))
      : "=m" (_tmp) : :
   );
}

The following is kind of a workaround (ok for 1 reference):

void test2()
{
   unsigned _tmp[8];
   __asm__ (
      "movl %%edi, %0"	// generates movl %edi, -28(%ebp)
      : "=m" (_tmp[3]) : :
   );
}

But somewhat onerous and error-prone for several references:

void test3()
{
   unsigned _tmp[8];
   __asm__ (
      "movl %%edi, %0      \n\t"
      "movl %%esi, %1      \n\t"
      "movl %%ebp, %2      \n\t"
      "movl %%ebx, %3      \n\t"
      "movl %%edx, %4      \n\t"
      "movl %%ecx, %5      \n\t"
      "movl %%eax, %6      \n\t"
      : "=m" (_tmp[0]), "=m" (_tmp[1]), "=m" (_tmp[2]),
        "=m" (_tmp[4]), "=m" (_tmp[5]), "=m" (_tmp[6]),
        "=m" (_tmp[7]
      : :
   );
}

On a separate note, is there any plan to implement __attribute__(__naked__)
for x86?  Restarting a processor exception is wicked tricky without being
able to alter the stack frame directly...


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux