SDL_endian.h: add Watcom inline asm for SDL_Swap16 and SDL_Swap32 SDL-1.2
authorOzkan Sezer <sezeroz@gmail.com>
Sat, 24 Mar 2018 22:27:31 +0300
branchSDL-1.2
changeset 11965afbe1aac2dd1
parent 11964 6c37a15030e7
child 11966 0c7962a4336f
SDL_endian.h: add Watcom inline asm for SDL_Swap16 and SDL_Swap32
include/SDL_endian.h
     1.1 --- a/include/SDL_endian.h	Sat Mar 24 22:25:33 2018 +0300
     1.2 +++ b/include/SDL_endian.h	Sat Mar 24 22:27:31 2018 +0300
     1.3 @@ -97,6 +97,12 @@
     1.4  	__asm__("rorw #8,%0" : "=d" (x) :  "0" (x) : "cc");
     1.5  	return x;
     1.6  }
     1.7 +#elif defined(__WATCOMC__) && defined(__386__)
     1.8 +extern _inline Uint16 SDL_Swap16(Uint16);
     1.9 +#pragma aux SDL_Swap16 = \
    1.10 +	"xchg al, ah" \
    1.11 +	parm   [ax]   \
    1.12 +	modify [ax];
    1.13  #else
    1.14  static __inline__ Uint16 SDL_Swap16(Uint16 x) {
    1.15  	return SDL_static_cast(Uint16, ((x<<8)|(x>>8)));
    1.16 @@ -132,6 +138,21 @@
    1.17  	__asm__("rorw #8,%0\n\tswap %0\n\trorw #8,%0" : "=d" (x) :  "0" (x) : "cc");
    1.18  	return x;
    1.19  }
    1.20 +#elif defined(__WATCOMC__) && defined(__386__)
    1.21 +extern _inline Uint32 SDL_Swap32(Uint32);
    1.22 +#ifndef __SW_3 /* 486+ */
    1.23 +#pragma aux SDL_Swap32 = \
    1.24 +	"bswap eax"  \
    1.25 +	parm   [eax] \
    1.26 +	modify [eax];
    1.27 +#else  /* 386-only */
    1.28 +#pragma aux SDL_Swap32 = \
    1.29 +	"xchg al, ah"  \
    1.30 +	"ror  eax, 16" \
    1.31 +	"xchg al, ah"  \
    1.32 +	parm   [eax]   \
    1.33 +	modify [eax];
    1.34 +#endif
    1.35  #else
    1.36  static __inline__ Uint32 SDL_Swap32(Uint32 x) {
    1.37  	return SDL_static_cast(Uint32, ((x<<24)|((x<<8)&0x00FF0000)|((x>>8)&0x0000FF00)|(x>>24)));