00001
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef FIXED_ARM4_H
00036 #define FIXED_ARM4_H
00037
00038 #undef MULT16_32_Q14
00039 static inline spx_word32_t MULT16_32_Q14(spx_word16_t x, spx_word32_t y) {
00040 int res;
00041 int dummy;
00042 asm (
00043 "smull %0,%1,%2,%3 \n\t"
00044 "mov %0, %0, lsr #14 \n\t"
00045 "add %0, %0, %1, lsl #18 \n\t"
00046 : "=&r"(res), "=&r" (dummy)
00047 : "r"(y),"r"((int)x));
00048 return(res);
00049 }
00050
00051 #undef MULT16_32_Q15
00052 static inline spx_word32_t MULT16_32_Q15(spx_word16_t x, spx_word32_t y) {
00053 int res;
00054 int dummy;
00055 asm (
00056 "smull %0,%1,%2,%3 \n\t"
00057 "mov %0, %0, lsr #15 \n\t"
00058 "add %0, %0, %1, lsl #17 \n\t"
00059 : "=&r"(res), "=&r" (dummy)
00060 : "r"(y),"r"((int)x));
00061 return(res);
00062 }
00063
00064 #undef DIV32_16
00065 static inline short DIV32_16(int a, int b)
00066 {
00067 int res=0;
00068 int dead1, dead2, dead3, dead4, dead5;
00069 __asm__ __volatile__ (
00070 "\teor %5, %0, %1\n"
00071 "\tmovs %4, %0\n"
00072 "\trsbmi %0, %0, #0 \n"
00073 "\tmovs %4, %1\n"
00074 "\trsbmi %1, %1, #0 \n"
00075 "\tmov %4, #1\n"
00076
00077 "\tsubs %3, %0, %1, asl #14 \n"
00078 "\tmovpl %0, %3 \n"
00079 "\torrpl %2, %2, %4, asl #14 \n"
00080
00081 "\tsubs %3, %0, %1, asl #13 \n"
00082 "\tmovpl %0, %3 \n"
00083 "\torrpl %2, %2, %4, asl #13 \n"
00084
00085 "\tsubs %3, %0, %1, asl #12 \n"
00086 "\tmovpl %0, %3 \n"
00087 "\torrpl %2, %2, %4, asl #12 \n"
00088
00089 "\tsubs %3, %0, %1, asl #11 \n"
00090 "\tmovpl %0, %3 \n"
00091 "\torrpl %2, %2, %4, asl #11 \n"
00092
00093 "\tsubs %3, %0, %1, asl #10 \n"
00094 "\tmovpl %0, %3 \n"
00095 "\torrpl %2, %2, %4, asl #10 \n"
00096
00097 "\tsubs %3, %0, %1, asl #9 \n"
00098 "\tmovpl %0, %3 \n"
00099 "\torrpl %2, %2, %4, asl #9 \n"
00100
00101 "\tsubs %3, %0, %1, asl #8 \n"
00102 "\tmovpl %0, %3 \n"
00103 "\torrpl %2, %2, %4, asl #8 \n"
00104
00105 "\tsubs %3, %0, %1, asl #7 \n"
00106 "\tmovpl %0, %3 \n"
00107 "\torrpl %2, %2, %4, asl #7 \n"
00108
00109 "\tsubs %3, %0, %1, asl #6 \n"
00110 "\tmovpl %0, %3 \n"
00111 "\torrpl %2, %2, %4, asl #6 \n"
00112
00113 "\tsubs %3, %0, %1, asl #5 \n"
00114 "\tmovpl %0, %3 \n"
00115 "\torrpl %2, %2, %4, asl #5 \n"
00116
00117 "\tsubs %3, %0, %1, asl #4 \n"
00118 "\tmovpl %0, %3 \n"
00119 "\torrpl %2, %2, %4, asl #4 \n"
00120
00121 "\tsubs %3, %0, %1, asl #3 \n"
00122 "\tmovpl %0, %3 \n"
00123 "\torrpl %2, %2, %4, asl #3 \n"
00124
00125 "\tsubs %3, %0, %1, asl #2 \n"
00126 "\tmovpl %0, %3 \n"
00127 "\torrpl %2, %2, %4, asl #2 \n"
00128
00129 "\tsubs %3, %0, %1, asl #1 \n"
00130 "\tmovpl %0, %3 \n"
00131 "\torrpl %2, %2, %4, asl #1 \n"
00132
00133 "\tsubs %3, %0, %1 \n"
00134 "\tmovpl %0, %3 \n"
00135 "\torrpl %2, %2, %4 \n"
00136
00137 "\tmovs %5, %5, lsr #31 \n"
00138 "\trsbne %2, %2, #0 \n"
00139 : "=r" (dead1), "=r" (dead2), "=r" (res),
00140 "=r" (dead3), "=r" (dead4), "=r" (dead5)
00141 : "0" (a), "1" (b), "2" (res)
00142 : "cc"
00143 );
00144 return res;
00145 }
00146
00147
00148 #endif