## sdcc-user

 [Sdcc-user] pic 14 - integer multiplication and division From: Michele Sanges - 2007-06-14 06:36:48 ```Hi all, I work in a project with a 16F737 PIC (pic14); when I multiply or divide some integer values, the result is wrong. Any help is a lot appreciated. Best regards. Michele ```
 Re: [Sdcc-user] pic 14 - integer multiplication and division From: Raphael Neider - 2007-06-14 23:15:03 ```Hi Michele, > 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 details: 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 ;-) Raphael ```
 Re: [Sdcc-user] pic 14 - integer multiplication and division From: Raphael Neider - 2007-06-15 11:31:02 Attachments: usartoutput.patch muldiv.c muldiv.pl script.stc ```Hi again, 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) Results: 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 version). Regards, Raphael ```