Hi,
The CW doen't handle correctly inline asm command SMLALD.
CW version is 10.2 Special Edition. CPU is Kinetis K10, CPU-selection in compiler settings is cortex-m4.
CW doesn't recognize that arguments RdLo and RdHi are input/output parameters.
It handles those "output only" and uses CPU registers wrongly. "+r" doesn't help.
Operation can be corrected by adding dummy-command SMUAD, which uses RE_LO and RE_HI
and prevents optimization to rearrange CPU registers.
But those extra commands waste time in our time critical loop.
Can this bug corrected by patching some compiler file(s)?
Is this corrected in CW version 10.3?
~Mark
In header file:
#define ASM_SMUAD(Rd, Rn, Rm) \
({ asm volatile { smuad Rd, Rn, Rm } })
#define ASM_SMLALD(RdLo, RdHi, Rn, Rm) \
({ asm volatile ( "smlald %0, %1, %2, %3" : "+r" (RdLo), "+r" (RdHi) : "r" (Rn), "r" (Rm) ); })
In application SW:
in for-loop:
uint32_t dummy;
ASM_SMUAD( dummy, RE_LO, RE_HI ); // Dummy instruction to correct SMLALD by using RE_LO, RE_HI
ASM_SMLALD( RE_LO, RE_HI, X_VAL, COS_VAL );
ASM_SMUAD( dummy, IM_LO, IM_HI ); // Dummy instruction to correct SMLALD by using IM_LO, IM_HI
ASM_SMLALD( IM_LO, IM_HI, X_VAL, SIN_VAL );