gcc-4 inline assembler question (no register in class 'GENERAL_REGS' error)

Ulrich Drepper drepper at redhat.com
Sun May 1 20:58:48 UTC 2005


Enrico Scholz wrote:
>   asm("    fs movl %0, %%eax\n"
>       "    fs movl %1, %%ebx\n"
>       "    fs movl %2, %%ecx\n"
>       "    fs movl %3, %%edx\n"
>       "    fs movl %4, %%esp\n"
>       "    fs movl %5, %%ebp\n"
>       "    fs movl %6, %%esi\n"   // **
>       :
>       : "m" (Xoffsetof(CPUState, regs[0])),
> 	"m" (Xoffsetof(CPUState, regs[1])),
> 	"m" (Xoffsetof(CPUState, regs[2])),
> 	"m" (Xoffsetof(CPUState, regs[3])),
> 	"m" (Xoffsetof(CPUState, regs[4])),
> 	"m" (Xoffsetof(CPUState, regs[5])), // **
> 	"m" (Xoffsetof(CPUState, regs[6]))

This form is calling for trouble anyway.  Just use the following which
should work well with older gcc versions as well:

  asm("    fs movl %c0, %%eax\n"
      "    fs movl %c1, %%ebx\n"
      "    fs movl %c2, %%ecx\n"
      "    fs movl %c3, %%edx\n"
      "    fs movl %c4, %%esp\n"
      "    fs movl %c5, %%ebp\n"
      "    fs movl %c6, %%esi\n"
      :
      : "i" (offsetof(CPUState, regs[0])),
        "i" (offsetof(CPUState, regs[1])),
        "i" (offsetof(CPUState, regs[2])),
        "i" (offsetof(CPUState, regs[3])),
        "i" (offsetof(CPUState, regs[4])),
        "i" (offsetof(CPUState, regs[5])),
        "i" (offsetof(CPUState, regs[6]))
    );


-- 
➧ Ulrich Drepper ➧ Red Hat, Inc. ➧ 444 Castro St ➧ Mountain View, CA ❖

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 251 bytes
Desc: OpenPGP digital signature
Url : http://lists.fedoraproject.org/pipermail/devel/attachments/20050501/5b1ab69f/attachment-0002.bin 


More information about the devel mailing list