#1242 PIC14 - incorrect unsigned int addition

closed-fixed
nobody
5
2013-05-25
2006-11-19
Anonymous
No

Current snapshot (2.6.1 #4472) contains some bug in code generation for unsigned int (and unsigned short) addition. Result is incorrect for some values of operands.

My sample code:
#include "pic16f84.h"
void main()
{
volatile unsigned int i,j,k;

TRISB=0;

i=0x06f4;
j=0x037a;
k=i+j; // 0x06f4+0x037a=0x0a6e

PORTB=k>>8; // just to verify MSB of result
for (;;);
}

Result k should be 0xa6e, but is 0x66e.

command used:
sdcc -mpic14 -p16f84 addtest.c

SDCC : mcs51/gbz80/z80/avr/ds390/pic16/pic14/TININative/xa51/ds400/hc08 2.6.1 #4472 (Nov 18 2006) (UNIX)

This problem doesn't appear in last stable version (2.6.0 #4309 (Jul 28 2006) (UNIX)_.

Discussion

  • Raphael Neider

    Raphael Neider - 2006-11-20

    Logged In: YES
    user_id=1115835
    Originator: NO

    Fixed in SDCC r4473.

    The culprit was---of course---the BANKSEL insertion code; this time, INCFSZ was turned into a NOP, just for the fun of it...

     
  • Raphael Neider

    Raphael Neider - 2006-11-20
    • milestone: --> fixed
    • status: open --> closed-fixed
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks