title: extended asm in gcc: ‘asm’ operand has impossible constraints
body: <p>This function "strcpy" aims to copy the content of <em>src</em> to <em>dest</em>, and it works out just fine: display two lines of "Hello_src".</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  static inline char * strcpy(char * dest,const char *src)
  {
      int d0, d1, d2;
      __asm__ __volatile__("1:\tlodsb\n\t"
                           "stosb\n\t"
                           "testb %%al,%%al\n\t"
                           "jne 1b"
                           : "=&amp;S" (d0), "=&amp;D" (d1), "=&amp;a" (d2)
                           : "0"(src),"1"(dest)
                           : "memory");
      return dest;
  }
  
  int main(void) {
      char src_main[] = "Hello_src";
      char dest_main[] = "Hello_des";
      strcpy(dest_main, src_main);
      puts(src_main);
      puts(dest_main);
      return 0;
  }
  </code></pre>
  
  <ol>
  <li><p>I tried to change the line <code>: "0"(src),"1"(dest)</code> to <code>: "S"(src),"D"(dest)</code>, the error occurred: <code>‘asm’ operand has impossible constraints</code>. I just cannot understand. I thought that "0"/"1" here specified the same constraint as the 0th/1th output variable. the constraint of 0th output is <code>=&amp;S</code>, te constraint of 1th output is <code>=&amp;D</code>. If I change 0-->S, 1-->D, there shouldn't be any wrong. What's the matter with it?</p></li>
  <li><p>Does "clobbered registers" or the earlyclobber operand(&amp;) have any use? I try to remove "&amp;" or "memory", the result of either circumstance is the same as the original one: output two lines of "Hello_src" strings. So why should I use the "clobbered" things?</p></li>
  </ol>