[FFmpeg-devel] m68k code for bswap
ami_stuff
ami_stuff
Wed Jul 1 15:07:10 CEST 2009
Hi,
Here is m68k asm-optimized code for bswap.
Maybe someone with more knowledge can add it to "libavutil/bswap.h" file.
#ifndef ENDIAN_H
#define ENDIAN_H
#ifdef __X86__
#define LITTLE_ENDIAN 1
#endif
#ifdef __M68K__ // use 68k inline routines
int64 endian64(__reg("d0/d1") int64) =
"\tmove.l\td1,d2\n"
"\tmove.l\td0,d1\n"
"\tmove.l\td2,d0\n"
"\trol.w\t#8,d0\n"
"\trol.w\t#8,d1\n"
"\tswap\td0\n"
"\tswap\td1\n"
"\trol.w\t#8,d0\n"
"\trol.w\t#8,d1";
int32 endian32(__reg("d0") int32) =
"\trol.w\t#8,d0\n"
"\tswap\td0\n"
"\trol.w\t#8,d0";
int16 endian16(__reg("d0") int16) =
"\trol.w\t#8,d0";
#else // use generic C routines
#define endian32(A) \
(((uint32)(A&0xFF000000)>>24)+((uint32)(A&0xFF0000)>>8))+((uint32)(A&0xFF00)<<8) \
+((uint32)(A&0xFF)<<24))
#define endian16(A) \
(((uint32)(A&0xFF00)>>8))+((uint32)(A&0xFF)<<8))
#endif
#ifdef LITTLE_ENDIAN
#define be2nat16(A) endian16(A)
#define be2nat32(A) endian32(A)
#define le2nat16(A) (A)
#define le2nat32(A) (A)
#define nat2be16(A) endian16(A)
#define nat2be32(A) endian32(A)
#define nat2le16(A) (A)
#define nat2le32(A) (A)
#else
#define be2nat16(A) (A)
#define be2nat32(A) (A)
#define le2nat16(A) endian16(A)
#define le2nat32(A) endian32(A)
#define nat2be16(A) (A)
#define nat2be32(A) (A)
#define nat2le16(A) endian16(A)
#define nat2le32(A) endian32(A)
#endif
#endif /* ENDIAN_H */
The website's owner is author of the m68k asm-inlines.
http://web.archive.org/web/20050216094707/http://a500.org/downloads/source/endian.h
Regards
More information about the ffmpeg-devel
mailing list