the problem seems solved.
special thanks tor user "prx" at mikrocontroller.net.
http://www.mikrocontroller.net/topic/252696#new
the compiler switch -mfloat_abi=softfp seems to be right. It ensures the right mix of calling subroutines in case of using "double" values not handled by the fpu and the correct assembler code involving the fpu at cortex-m4 -otherwise.
USE_OPT = -ggdb -fomit-frame-pointer -falign-functions=16 -mfloat-abi=softfp -mfpu=fpv4-sp-d16 -fsingle-precision-constant
MPU = cortex-m4
CORTEX_USE_FPU TRUE
Code: Select all
dy = 168.0;
fx = (float)dy;
dy = 202.0;
fy = 197.0;
fz = 12.2;
float d = (float)dy * fx * fy * fz;
intx = (int)fx;
inty = (int)dy;
intz = (int)d;
assembler:
08029bda: ldrd r0, r1, [sp, #64] ; 0x40
08029bde: bl 0x8000a90 <__truncdfsf2>
08029be2: vmov s14, r0
08029be6: vldr s15, [sp, #60] ; 0x3c
08029bea: vmul.f32 s14, s14, s15
08029bee: vldr s15, [sp, #56] ; 0x38
08029bf2: vmul.f32 s14, s14, s15
08029bf6: vldr s15, [sp, #52] ; 0x34
08029bfa: vmul.f32 s15, s14, s15
08029bfe: vstr s15, [sp, #48] ; 0x30
141 intx = (int)fx;
08029c02: vldr s15, [sp, #60] ; 0x3c
08029c06: vcvt.s32.f32 s15, s15
08029c0a: vmov r3, s15
08029c0e: str r3, [sp, #44] ; 0x2c
142 inty = (int)dy;
08029c10: ldrd r0, r1, [sp, #64] ; 0x40
08029c14: bl 0x8000a40 <__fixdfsi>
08029c18: mov r3, r0
08029c1a: str r3, [sp, #40] ; 0x28
143 intz = (int)d;
08029c1c: vldr s15, [sp, #48] ; 0x30
08029c20: vcvt.s32.f32 s15, s15
08029c24: vmov r3, s15
08029c28: str r3, [sp, #36] ; 0x24
i thin it would be a good idea to change the compiler settings inside the makefile and set the use of the fpu to "on"
There is one question left to Giovanni. As far i can see the complier starts using registes s15, s14.... maybe downto s0.
In the context swich routine i can see that only registers s16 - s31 are saved.... is this right or is this wrong ?
Code: Select all
void _port_switch(Thread *ntp, Thread *otp) {
asm volatile ("push {r4, r5, r6, r7, r8, r9, r10, r11, lr}"
: : : "memory");
#if CORTEX_USE_FPU
asm volatile ("vpush {s16-s31}" : : : "memory");
#endif
asm volatile ("str sp, [%1, #12] \n\t"
"ldr sp, [%0, #12]" : : "r" (ntp), "r" (otp));
#if CORTEX_USE_FPU
asm volatile ("vpop {s16-s31}" : : : "memory");
#endif
asm volatile ("pop {r4, r5, r6, r7, r8, r9, r10, r11, pc}"
: : : "memory");
}
Cheers,
Thilo