From: George M. Gallant <ggallant571@co...> - 2004-10-06 23:33:27
There is a problem with the signed divide routines. They typically
return the negative of
the correct result. Futher digging seems to point at compound "if"
statements. I tried
two schemes to calculate the sign that failed.
The follow code snippet executes incorrectly:
char a, b, c;
a = 20;
b = 5;
c = a / b;
c returns 0xFC which is -4. Change b to -5 and c returns 4.
The following snippet also fails:
c = 0;
if ((a < 0) ^ (b < 0) c = 1;
These results were obtained on a 18f252 with sdcc 2.4.5.
BTW, the unsigned div routines which do most of the work seem ok.
From: Vangelis Rokas <vrokas@ot...> - 2004-10-07 01:36:09
----- Original Message -----
From: "George M. Gallant" <ggallant571@...>
Subject: [Sdcc-user] Signed divides
> There is a problem with the signed divide routines. They typically
> return the negative of the correct result. Futher digging seems to
> point at compound "if" statements. I tried two schemes to calculate
> the sign that failed.
Its time to fix this stupid bug... It will be the next thing to fix after I
finish debugging of functions with variable arguments and get
printf_small to work... (its difficult, believe me!)
Get latest updates about Open Source Projects, Conferences and News.