- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
i have a problem, code like this:
int _float2int(float f)
{
int i;
__asm fld f
__asm fistp i
return i;
}
{
int i;
__asm fld f
__asm fistp i
return i;
}
how to rewrite with gcc
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I assume you're asking about how to generally use gcc style asm?
For details try googling "gcc inline asm".
For details try googling "gcc inline asm".
If you've got MS style asm already, you could just use "icc -use-msasm" to avoid rewriting everything in gcc style. This should work as long as you don't mix the two (some system headers may contain gcc style inline asm)
I assume you're using inline asm to convert floats to ints for performance
reasons. In that case you may want to try using SSE instructions instead
of x87, which you could do with intrinsics such as _mm_cvtps_epi32(), thus avoiding inline asm entirely.
reasons. In that case you may want to try using SSE instructions instead
of x87, which you could do with intrinsics such as _mm_cvtps_epi32(), thus avoiding inline asm entirely.
Finally, if you're still determined to use gcc stylex87 assembly, you could try something like this:
__asm__("flds %1;
fistpl %0;": "=m" (i) : "m" (f));
fistpl %0;": "=m" (i) : "m" (f));
I believe in gnu style asm you need to specify the sizes as a suffix to the instruction name, hence "flds" and "fistpl".
Dale
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page