Hi, I have some problem when I'm using 'asm' in C++.
I need to find max value in array, I wrote the code but it doesn't compare.
What I have tried:
void func1(int x[],int lenght){
int max, z = x[0];
__asm__ volatile
(
"movl %1, %%eax;"
"movl %%eax, %0;"
: "=r" ( max )
: "r" ( z )
: "%eax"
);
for(int i = 1 ; i < lenght; i++)
{
__asm__ volatile
(
"movl %1, %%ebx;"
"cmpl %%ebx,%%eax;"
"jl DONE;"
"DONE: movl %%ebx,%%eax;"
"movl %%eax , %0"
:"=r"(max)
:"r"(x[i])
);
}
cout << "MAX" << endl;
cout << max << endl;
}