title: Extended Inline Assembly GCC- bad register name and junk 'done' after expression error when compiling
body: <p>I'm writing a program using assembly code to write a program that calculate one of the quadratic equation roots. I've written all of my code, but I have the following error:</p>
  
  <pre><code>main.c:37: Error: bad register name `%qword'
  main.c:39: Error: junk `done' after expression
  </code></pre>
  
  <p>How do I correct those error, please?</p>
  
  <p>My codes is:</p>
  
  <pre><code>// function for checking that assembly code is computing the correct result
  double quadraticRootC(double a, double b, double c)
  {
      return (-b + sqrt(b * b - 4 * a * c)) / (2 * a);
  }
  
  double quadraticRoot(double a, double b, double c)
  {
      double root;
  
      asm(
          "fld        %1              \n"
          "fadd       %%ST            \n"
          "fld        %1              \n"
          "fld        %3              \n"
          "fmulp      %%ST(1)         \n"
          "fadd       %%ST            \n"
          "fadd       %%ST            \n"
          "fchs                       \n"
          "fld        %2              \n"
          "fld        %2              \n"
          "fmulp      %%ST(1)         \n"
          "faddp      %%ST(1)         \n"
          "ftst                       \n"
          "fstsw      %%1X            \n"
          "sahf                       \n"
          "fsqrt                      \n"
          "fld        %2              \n"
          "fchs                       \n"
          "fdivp      %%ST(1)         \n"
          "mov        %0, %%eax    \n"
          "fstp       %%qword, %%eax  \n"
          "mov        $1, %%eax       \n"
          "jmp        short done      \n"
          "done:                      \n"
          :"=g"(root)
          :"g"(a), "g"(b), "g"(c)
          :"eax"
          );
      return(root);
  }
  
  int main(int argc, char **argv)
  {
      double  a, b, c;
      double  root, rootC;
  
      if (argc != 4) {
          printf("need 3 arguments: a, b, c\n");
          return -1;
      }
      a = atof(argv[1]);
      b = atof(argv[2]);
      c = atof(argv[3]);
      root = quadraticRoot(a, b, c);
      rootC = quadraticRootC(a, b, c);
  
      printf("quadraticRoot(%.3f, %.3f, %.3f) = %.3f, %.3f\n", a, b, c, root, rootC);
  
      return 0;
  }
  </code></pre>
  
  <p>The line where the error occurs:</p>
  
  <pre><code>"mov        %0, %%eax    \n"
  "fstp       %%qword, %%eax  \n"
  "mov        $1, %%eax       \n"
  </code></pre>
  
  <p>Any help would be appreciated.</p>