I’m having trouble compiling the code below. It may also have logical errors, please help. thanks,
#include <iostream>
using namespace std;
int main()
{
int shifted_value;
int value = 2;
__asm__("shll %%eax,%1;" : "=a" (shifted_value): "a" (value));
cout<<shifted_value<<endl;
return 0 ;
}
The error is:
Error: suffix or operands invalid for `shl’
It should look like
Credit for correct code goes to the other answer for pointing out that the operands were in the incorrect order.
You dont need to specify eax as clobbered because eax is an output register.