[MPlayer-dev-eng] Why cpuid so complex?

Zuxy Meng zuxy.meng at gmail.com
Sun Apr 23 09:13:15 CEST 2006


Hi,

MPlayer always uses cpuid in a ways like this:

    __asm __volatile
    ("mov %%"REG_b", %%"REG_S"\n\t"
         "cpuid\n\t"
         "xchg %%"REG_b", %%"REG_S
         : "=a" (p[0]), "=S" (p[1]),
           "=c" (p[2]), "=d" (p[3])
         : "0" (ax));
Or

  asm("push %%ebx; "
      "movl %4,%%eax; " CPUID
      "movl %%eax,%0; movl %%ebx,%1; movl %%ecx,%2; movl %%edx,%3; "
      "pop %%ebx"
      : "=m" (regs.eax), "=m" (regs.ebx), "=m" (regs.ecx), "=m" (regs.edx)
      : "g" (func)
      : "%eax", "%ecx", "%edx");

Why not the much simpler way, e.g.

    __asm __volatile(
    "cpuid;"
    : "=a" (p[0]), "=b" (p[1]), "=c" (p[2]), "=d" (p[3])
    :  "0" (ax)
    );

Saving ebx by hand sometimes breaks in icc and gcc -O, and what
problem would the last way cause?

--
Zuxy
Beauty is truth,
While truth is beauty.
PGP KeyID: E8555ED6




More information about the MPlayer-dev-eng mailing list