Skip navigation.
Home
The QNX Community Portal

View topic - Inline SH-4 assembly

Inline SH-4 assembly

For discussion of realtime and/or embedded programming.

Inline SH-4 assembly

Postby embeddedcoder » Mon Apr 13, 2009 9:42 pm

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; \
})
embeddedcoder
New Member
 
Posts: 3
Joined: Wed May 07, 2008 7:12 pm

Return to Realtime and Embedded

Who is online

Users browsing this forum: No registered users and 2 guests

cron