I'm trying to copy data from one array to another using inline assembly in C by using the rep movsd
, my code currently looks like this:
#include<stdio.h>
int main(){
int v1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
int v2[10];
asm ("mov %edi, v2\n"
"mov %esi, v1\n"
"mov %ecx, 40\n"
"rep movsd"
);
for(int i=0;i<10;i++){
printf("%d ", v2[i]);
}
printf("\n");
return 0;
}
But I keep getting an error saying that I can't use v2 and v1 in the following way:
Undefined symbol "v2" can't be used to make a PIE object
I couldn't find the correct syntax to add C pointers to the inline assembly.
I'm using the following version of gcc:
gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0