fixed : Traduction en ASM des dernières fonctions "simples"
This commit is contained in:
parent
c217e69ce8
commit
cd30c37210
Binary file not shown.
28
src/fixed.S
28
src/fixed.S
|
@ -15,6 +15,9 @@
|
|||
.global _feasein
|
||||
.type _feasein, @function
|
||||
|
||||
.global _fease
|
||||
.type _fease, @function
|
||||
|
||||
_fmul:
|
||||
dmuls.l r4, r5
|
||||
sts MACH, r1
|
||||
|
@ -37,7 +40,7 @@ _fceil:
|
|||
shad r1, r0
|
||||
|
||||
_fround:
|
||||
mov.l .fround_constant, r0
|
||||
mov.l .half_constant, r0
|
||||
add r4, r0
|
||||
mov #-16, r1
|
||||
rts
|
||||
|
@ -51,5 +54,26 @@ _feasein:
|
|||
rts
|
||||
xtrct r1, r0
|
||||
|
||||
.fround_constant:
|
||||
_fease:
|
||||
mov.l .half_constant, r1
|
||||
cmp/gt r1, r4
|
||||
bf fease_sml
|
||||
nop
|
||||
mov #-1, r2
|
||||
extu.w r2, r2
|
||||
sub r2, r4
|
||||
mov r4, r5
|
||||
bra _fmul
|
||||
mov #-1, r3
|
||||
shad r3, r0
|
||||
rts
|
||||
sub r2, r0
|
||||
fease_sml:
|
||||
mov r4, r5
|
||||
bra _fmul
|
||||
mov #-1, r3
|
||||
rts
|
||||
sub r2, r0
|
||||
|
||||
.half_constant:
|
||||
.long 0x8000
|
||||
|
|
28
src/fixed.h
28
src/fixed.h
|
@ -11,7 +11,7 @@ typedef int32_t fixed_t;
|
|||
/* Standard arithmetic. */
|
||||
|
||||
//GCC complained when in inline functions
|
||||
#define ffloor(f) ((f) >> 16)
|
||||
#define ffloor(f) ((int)(f) >> 16)
|
||||
|
||||
#ifndef FXCG50
|
||||
|
||||
|
@ -42,6 +42,17 @@ static inline fixed_t feasein(fixed_t x)
|
|||
return fmul(x, x);
|
||||
}
|
||||
|
||||
static inline fixed_t fease(fixed_t x)
|
||||
{
|
||||
if(x <= fix(0.5)) {
|
||||
return 2 * fmul(x, x);
|
||||
}
|
||||
else {
|
||||
x = fix(1) - x;
|
||||
return fix(1) - 2 * fmul(x, x);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifdef FXCG50
|
||||
|
||||
|
@ -53,7 +64,9 @@ extern inline int fceil(fixed_t f);
|
|||
|
||||
extern inline int fround(fixed_t f);
|
||||
|
||||
inline fixed_t feasein(fixed_t x);
|
||||
extern inline fixed_t feasein(fixed_t x);
|
||||
|
||||
extern inline fixed_t fease(fixed_t x);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -90,14 +103,3 @@ static inline double f2int(fixed_t f)
|
|||
{
|
||||
return (int)f / 65536;
|
||||
}
|
||||
|
||||
static inline fixed_t fease(fixed_t x)
|
||||
{
|
||||
if(x <= fix(0.5)) {
|
||||
return 2 * fmul(x, x);
|
||||
}
|
||||
else {
|
||||
x = fix(1) - x;
|
||||
return fix(1) - 2 * fmul(x, x);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue