I'm trying to use extended assembly to divide an array of 32bit floats located in a 4float vector structure.
This is the compiler error:
sisd.c: In function ‘divSISD’:
sisd.c:182:9: error: ‘asm’ operand has impossible constraints
asm(
^~~
Code:
void divSISD(Vector4f* vecA, Vector4f* vecB, Vector4f* result, int size){
for(int i = 0; i < size; i++){
asm(
"fld %4\n\t"
"fdiv %5\n\t"
"fstp %0\n\t"
"fld %6\n\t"
"fdiv %7\n\t"
"fstp %1\n\t"
"fld %8\n\t"
"fdiv %9\n\t"
"fstp %2\n\t"
"fld %10\n\t"
"fdiv %11\n\t"
"fstp %3\n\t"
: "=m" (result[i].a),
"=m" (result[i].b),
"=m" (result[i].c),
"=m" (result[i].d)
: "m" (vecA[i].a), "m" (vecB[i].a),
"m" (vecA[i].b), "m" (vecB[i].b),
"m" (vecA[i].c), "m" (vecB[i].c),
"m" (vecA[i].d), "m" (vecB[i].d)
);
}
}
This appears to work fine if I use the non pointer struct type, like this:
void divSISD(Vector4f vecA, Vector4f vecB, Vector4f result, int size){
asm(
"fld %4\n\t"
"fdiv %5\n\t"
"fstp %0\n\t"
"fld %6\n\t"
"fdiv %7\n\t"
"fstp %1\n\t"
"fld %8\n\t"
"fdiv %9\n\t"
"fstp %2\n\t"
"fld %10\n\t"
"fdiv %11\n\t"
"fstp %3\n\t"
: "=m" (result.a),
"=m" (result.b),
"=m" (result.c),
"=m" (result.d)
: "m" (vecA.a), "m" (vecB.a),
"m" (vecA.b), "m" (vecB.b),
"m" (vecA.c), "m" (vecB.c),
"m" (vecA.d), "m" (vecB.d)
);
}
I can't understand why this wouldn't work as the "m" constraint should apply to both of the situations.