what is the proper asm spec for xchg

John-Mark Gurney gurney_j at resnet.uoregon.edu
Thu Dec 23 12:23:06 PST 2004


Sean McNeil wrote this message on Thu, Dec 23, 2004 at 11:31 -0800:
> I'm looking at why audio/sdl_mixer will not compile and I see that
> devel/sdl12 has an include with
> 
> #elif defined(__GNUC__) && defined(__x86_64__)
> static __inline__ Uint16 SDL_Swap16(Uint16 x)
> {
>         __asm__("xchgb %b0,%h0" : "=q" (x) :  "0" (x));
>         return x;
> }
> 
> This appears to be incorrect as it is giving errors when compiled.  Does
> anyone more conversant with asm directives for amd64 have an idea what
> this should be?

well, from amd64/include/endian.h:
#define __byte_swap_word_var(x) \
__extension__ ({ register __uint16_t __X = (x); \
   __asm ("xchgb %h0, %b0" : "+Q" (__X)); \
   __X; })

-- 
  John-Mark Gurney				Voice: +1 415 225 5579

     "All that I will do, has been done, All that I have, has not."


More information about the freebsd-amd64 mailing list