title: Operands mismatch for mul when inserting asm into c
body: <p>I'm trying to make an assembly insert into C code. However when I try to multiply two registers inside it I get an error calling for operands mismatch. I tried <code>"mul %%bl, %%cl\n"</code> (double %% because it's in C code). From my past experience with asm I think this should work. I also tried <code>"mul %%cl\n"</code> (moving bl to al first), but in this case I get tons of errors from linker</p>
  
  <pre><code>zad3:(.rodata+0x4): multiple definition of `len'
  /tmp/ccJxYyIp.o:(.rodata+0x0): first defined here
  zad3: In function `_fini':
  (.fini+0x0): multiple definition of `_fini'
  /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crti.o:(.fini+0x0): first defined here
  zad3: In function `data_start':
  (.data+0x0): multiple definition of `__data_start'
  /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crt1.o:(.data+0x0): first defined here
  zad3: In function `data_start':
  (.data+0x8): multiple definition of `__dso_handle'
  /usr/lib/gcc/x86_64-linux-gnu/5/crtbegin.o:(.data+0x0): first defined here
  zad3:(.rodata+0x0): multiple definition of `_IO_stdin_used'
  /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crt1.o:(.rodata.cst4+0x0): first defined here
  zad3: In function `_start':
  (.text+0x0): multiple definition of `_start'
  /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crt1.o: (.text+0x0): first defined here
  zad3: In function `data_start':
  (.data+0x10): multiple definition of `str'
  /tmp/ccJxYyIp.o:(.data+0x0): first defined here
  /usr/bin/ld: Warning: size of symbol `str' changed from 4 in   /tmp/ccJxYyIp.o to 9 in zad3
  zad3: In function `main':
  (.text+0xf6): multiple definition of `main'
  /tmp/ccJxYyIp.o:zad3.c:(.text+0x0): first defined here
  zad3: In function `_init':
  (.init+0x0): multiple definition of `_init'
  /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crti.o:(.init+0x0): first defined here
  /usr/lib/gcc/x86_64-linux-gnu/5/crtend.o:(.tm_clone_table+0x0): multiple definition of `__TMC_END__'
  zad3:(.data+0x20): first defined here
  /usr/bin/ld: error in zad3(.eh_frame); no .eh_frame_hdr table will be created.
  collect2: error: ld returned 1 exit status
  </code></pre>
  
  <p>From what I understand, it tells me I defined len and a few other variables a few times, but I cannot see this multiple definition.
  The goal of my program is to take a string of numbers and count sum of them but using 2 as a base. So let's say string is 293, then I want to count <code>2*2^2+9*2^1+3*2^0</code>
  Code: </p>
  
  <pre><code>#include &lt;stdio.h&gt;
  char str[] = "543";
  const int len = 3;
  
  int main(void)
  {
  asm(
  "mov $0, %%rbx \n"
  "mov $1, %%rcx \n"
  
  "potega: \n" 
  "shl $1, %%cl \n" 
  "inc %%rbx \n"
  "cmp len, %%ebx \n"
  "jl potega \n"
  
  
  "mov $0, %%rbx \n" 
  
  "petla: \n" 
  "mov (%0, %%rbx, 1), %%al \n" 
  
  "sub $48, %%al \n"
  
  "mul %%al, %%cl \n"  
  "shr $1, %%cl \n"    
  
  "add $48, %%al \n"
  
  "mov %%al, (%0, %%rbx, 1) \n" 
  
  "inc %%rbx \n"  
  "cmp len, %%ebx \n" 
  "jl petla \n" 
  
  :"r"(&amp;str)
  :"%rax", "%rbx", "%rcx" 
  );
  printf("Wynik: %s\n", str);
  return 0;
  }
  </code></pre>