The other day I was reading a document about inline assembly (http://www.delorie.com/djgpp/doc/bre...ine_djgpp.html).
I got stuck at the rep_movsl code. I tried ruing it on my PC. At first I got no error when it was the only thing in the code. But when I tried to actually use it, the compiler complained "‘asm’ operand has impossible constraints".
I am unable to figure out my way. I have already googled about it, but all vain.
I was wondering if there was something wrong with my compiling command. All I am using is "gcc code.c".
I would be great if anyone could look at my code (below) and help me out.
Thnx.
Code:
#include <stdio.h>
#define rep_movsl(src, dest, numwords)
__asm__ __volatile__ (
"cldnt"
"repnt"
"movsl"
: : "S" (src), "D" (dest), "c" (numwords)
: "%ecx", "%esi", "%edi" )
int main(int argc, char const *argv[])
{
int arr1[4] = {1, 2, 3, 4};
int arr2[4];
rep_movsl(arr1, arr2, 4);
int i;
for(i=0;i<4;++i)
printf("%d ",arr2[i]);
retu 0;
}
برچسب:
نویسنده: استخدام کار