Closed GoogleCodeExporter closed 9 years ago
I've not had a chance to test these recent changes but I can confirm that the
r49 code works just fine, so you're best bet on a quick solution is to revert
your copy of fix16.c to revision 49 and work with that until this can be solved.
Sorry for the inconvenience.
Original comment by ben.bre...@codethink.co.uk
on 3 May 2012 at 10:01
Original comment by Flatmush@googlemail.com
on 3 May 2012 at 10:04
Could not reproduce bug on x86 using the attached test.c. I'll try with
cortex-m3 later today.
Original comment by Petteri.Aimonen
on 3 May 2012 at 10:17
Attachments:
@SHAGGYNEMISIS
Can you provide the compiler options you are using, and also the exact compiler
version?
Original comment by Petteri.Aimonen
on 3 May 2012 at 10:22
Some other temporary replacement code you could use is this fast-newton-raphson
algorithm:
fix16_t rcp(fix16_t b)
{
bool n = (b < 0);
if (n) b = -b;
int s = 0;
for (; b > fix16_one; b >>= 1, s--);
for (; b < (fix16_one >> 1); b <<= 1, s++);
fix16_t x
= 185043 - fix16_mul(b, 123362);
unsigned i;
for (i = 0; i < 3; i++)
x = fix16_mul(x, (0x00020000 - fix16_mul(b, x)));
x <<= s;
return (n ? -x : x);
}
fix16_t fdiv(fix16_t a, fix16_t b)
{
return fix16_mul(a, rcp(b));
}
Original comment by Flatmush@googlemail.com
on 3 May 2012 at 10:36
@Flatmush
Fails for 15.0 / 5.0 etc. I don't think such temporary hacks are necessary, I
can fix the bug as soon as I can reproduce it. It is most probably some
compiler-specific issue, because the unittests would catch it otherwise.
Original comment by Petteri.Aimonen
on 3 May 2012 at 10:45
gimme me few mins ill provide the makefile and the code
Original comment by SHAGGYNE...@gmail.com
on 3 May 2012 at 10:49
the fpArith.c contains the part of the code that i need for my working..
Original comment by SHAGGYNE...@gmail.com
on 3 May 2012 at 10:51
Attachments:
[deleted comment]
Nope this didn't give the desired result
Div (-2) 0xfffe0000, (-1)0xffff0000 = 0x80000000
Original comment by SHAGGYNE...@gmail.com
on 3 May 2012 at 11:01
Try the test.c I attached in comment 3. Your code is too messy and I can't get
it easily to compile.
I tried the test.c on Cortex-M3 simulator also, the division works just fine.
Original comment by Petteri.Aimonen
on 3 May 2012 at 12:05
Yes i did try the test.c file the result is the same.. i.e. incorrect answer.
I will post the cleaned up test file soon.. Sorry to keep you waiting
Original comment by SHAGGYNE...@gmail.com
on 4 May 2012 at 5:18
Ok, good to know that test.c gives incorrect answer. Can you still give the gcc
version, you can get it with "arm-none-eabi-gcc --version".
Original comment by Petteri.Aimonen
on 4 May 2012 at 5:32
arm-none-eabi-gcc (Sourcery G++ Lite 2010q1-188) 4.4.1
Copyright (C) 2009 Free Software Foundation, Inc.
Original comment by SHAGGYNE...@gmail.com
on 4 May 2012 at 5:35
Hmm, I cannot repeat the bug using that compiler version either. Could you post
also the .elf file from your test.c compilation?
Original comment by Petteri.Aimonen
on 4 May 2012 at 5:41
Might take a while will try asap.. :)
Original comment by SHAGGYNE...@gmail.com
on 4 May 2012 at 5:44
fyi this is compilation command ...
arm-none-eabi-g++ -mcpu=cortex-m3 -mthumb -mfpu=vfp -msoft-float
-mfloat-abi=soft -O0 -Wl,-Map=main.map,--cref,--gc-sect
ions -lc -lm -lgcc -lstdc++ -T..//Common/LPC17xx.ld
I will post the elf.. soon
Original comment by SHAGGYNE...@gmail.com
on 4 May 2012 at 5:47
If there's nothing new on this thread then I'm going to close it since the bug
can't be reproduced and is very likely a compiler/code issue.
Original comment by Flatmush@googlemail.com
on 29 May 2012 at 3:14
Original comment by Flatmush@googlemail.com
on 26 Jul 2012 at 4:00
Original issue reported on code.google.com by
SHAGGYNE...@gmail.com
on 3 May 2012 at 9:48