> when I multiply or divide some integer values,
> the result is wrong. Any help is a lot appreciated.
I'd like to be of help, but you could help quite a bit if you gave more
For which operand types (char, int, long, signed or unsigned?) and
actual values do the operations fail?
Which SDCC version are you using?
Awaiting further orders ;-)
I just ran a couple of (semi-automated) tests and find arithmetics are
ok. For your reference, I attached the test suite and verifier.
To run, you need to patch gpsim-0.22.0 (see attached patch),
sdcc -mpic14 -p16f877 muldiv.c
gpsim -s muldiv.cod -c script.stc > output.log
perl muldiv.pl < output.log | less
(assuming you work on a Linux-like box).
Though Perl ain't good at verifying negative-valued results/operands,
you can manually verify the results: each line prints
.>>> (first operand) @@@ (second operand) *** (product) /// (quotient)
Division by 0 yields unexpected results: -1 (0xFFFFFFFF) if the first
operand is >= 0 (or unsigned), +1 (0x00000001) if the first operand is
less than 0 (result would be negative, so -1 is flipped...).
Tested with sdcc 2.7.2, r4852, gputils 0.13.4 beta (might be some CVS