Hello,
I'm trying to use the IQmath library with Stellaris LM4F.
Everything seems to compile right, but I've written a simple code:
#define PI 3.14159265359
#define PI2 _IQ21((float)PI)
float n1, n2;
n1=_IQ21toF(PI2);
n2=0; // for breakpoint
And now I debug it (optimization level: off, optimization for speed: 0, floating point mode: strict). After reaching breakpoint the CCS shows n1=0.
View of the disassembly code:
n1=_IQ21toF(PI2);
00000626: 4805 LDR R0, $C$CON1
00000628: F000F81E BL $C:/DriverLib/build/DriverLib.test/IQmath/ti/IQNtoF.asm:1275:1328$
0000062c: ED8D0A04 FSTS S0, [R13, #16]
It's interesting, since trace "C:/DriverLib/build/DriverLib.test/IQmath/ti/IQNtoF.asm" doesn't exist, but never mind.
The "$C:/DriverLib/build/DriverLib.test/IQmath/ti/IQNtoF.asm:1275:1328$" disasembled code:
$C:/DriverLib/build/DriverLib.test/IQmath/ti/IQNtoF.asm:1275:1328$, _IQ21toF:
00000668: B178 CZBEQ R0, r0isZero21
0000066a: F0104100 ANDS.W R1, R0, #2147483648
0000066e: BF48 IT MI
00000670: 4240 NEG R0, R0
00000672: FAB0F380 CLZ.W R3, R0
00000676: F1C30289 RSB.W R2, R3, #137
0000067a: FA00F003 LSL.W R0, R0, R3
0000067e: EA4F2010 MOV.W R0, R0, LSR #8
00000682: F36250DE BFI.W R0, R2, #23, #8
00000686: EA410000 ORR.W R0, R1, R0
r0isZero21:
0000068a: 4770 BX R14
Can you tell me find what is wrong? I've tried an _IQ21cos function and it probably works (result is !=0 ), so the library seems be used ok.