00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00029 #ifndef __CDIO_BYTESEX_ASM_H__
00030 #define __CDIO_BYTESEX_ASM_H__
00031 #if !defined(DISABLE_ASM_OPTIMIZE)
00032
00033 #include <cdio/types.h>
00034
00035 #if defined(__powerpc__) && defined(__GNUC__)
00036
00037 inline static
00038 uint32_t uint32_swap_le_be_asm(const uint32_t a)
00039 {
00040 uint32_t b;
00041
00042 __asm__ ("lwbrx %0,0,%1"
00043 :"=r"(b)
00044 :"r"(&a), "m"(a));
00045
00046 return b;
00047 }
00048
00049 inline static
00050 uint16_t uint16_swap_le_be_asm(const uint16_t a)
00051 {
00052 uint32_t b;
00053
00054 __asm__ ("lhbrx %0,0,%1"
00055 :"=r"(b)
00056 :"r"(&a), "m"(a));
00057
00058 return b;
00059 }
00060
00061 #define UINT16_SWAP_LE_BE uint16_swap_le_be_asm
00062 #define UINT32_SWAP_LE_BE uint32_swap_le_be_asm
00063
00064 #elif defined(__mc68000__) && defined(__STORMGCC__)
00065
00066 inline static
00067 uint32_t uint32_swap_le_be_asm(uint32_t a __asm__("d0"))
00068 {
00069
00070
00071 __asm__("move.l %1,d0;rol.w #8,d0;swap d0;rol.w #8,d0;move.l d0,%0"
00072 :"=r"(a)
00073 :"r"(a));
00074
00075 return(a);
00076 }
00077
00078 inline static
00079 uint16_t uint16_swap_le_be_asm(uint16_t a __asm__("d0"))
00080 {
00081 __asm__("move.l %1,d0;rol.w #8,d0;move.l d0,%0"
00082 :"=r"(a)
00083 :"r"(a));
00084
00085 return(a);
00086 }
00087
00088 #define UINT16_SWAP_LE_BE uint16_swap_le_be_asm
00089 #define UINT32_SWAP_LE_BE uint32_swap_le_be_asm
00090
00091 #elif 0 && defined(__i386__) && defined(__GNUC__)
00092
00093 inline static
00094 uint32_t uint32_swap_le_be_asm(uint32_t a)
00095 {
00096 __asm__("xchgb %b0,%h0\n\t"
00097 "rorl $16,%0\n\t"
00098 "xchgb %b0,%h0"
00099 :"=q" (a)
00100 : "0" (a));
00101
00102 return(a);
00103 }
00104
00105 inline static
00106 uint16_t uint16_swap_le_be_asm(uint16_t a)
00107 {
00108 __asm__("xchgb %b0,%h0"
00109 : "=q" (a)
00110 : "0" (a));
00111
00112 return(a);
00113 }
00114
00115 #define UINT16_SWAP_LE_BE uint16_swap_le_be_asm
00116 #define UINT32_SWAP_LE_BE uint32_swap_le_be_asm
00117
00118 #endif
00119
00120 #endif
00121 #endif
00122
00123
00124
00125
00126
00127
00128
00129
00130