Inline SH-4 assembly

I’m trying to get some optimized math functions working using inline SH-4 assembly running on QNX Neutrino. The following FastFabs routine works fine, but when i run the next routine Vec3LengthFast i’m getting incorrect results.

Can anyone tell me if i’m using the correct syntax for passing in values etc for inline SH-4 assembly? As i say it seems to work ok for the FastFabs function but not for Vec3LengthFast. I also tried a simple floating point multiplication which also failed. This leads me to think there’s something wrong whenever i pass in more that one parameter.

Thanks


#define FastFabs(val) ({
register float __val asm(“fr0”) = (val);
register float __result asm(“fr0”);
asm volatile(
“fabs fr0\n”
: “=f” (__result)
: “f” (__val)
);
__result;
})

#define Vec3LengthFast(x, y, z) ({
register float __x asm(“fr0”) = (x);
register float __y asm(“fr1”) = (y);
register float __z asm(“fr2”) = (z);
register float __result asm(“fr3”);
asm volatile(
“fldi0 fr3\n”
“fipr fv0,fv0\n”
“fsqrt fr3\n”
: “=f” (__result)
: “f” (__x), “f” (__y), “f” (__z)
);
__result;
})