Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22118

Inline assembly multiplication "undefined reference" on inputs

$
0
0

Trying to multiply 400 by 2 with inline assembly, using the fact imul implicity multiplies by eax. However, i'm getting "undefined reference" compile errors to $1 and $2

 int c;
 int a = 400;
 int b = 2;

 __asm__(
  ".intel_syntax;""mov eax, $1;""mov ebx, $2;""imul %0, ebx;"".att_syntax;"
  : "=r"(c)
  : "r" (a), "r" (b)
  : "eax");

std::cout << c << std::endl;

Viewing all articles
Browse latest Browse all 22118


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>