gnupic@linuxhacker.org

gnupic@linuxhacker.org


Subject: Re: More on SDCC/PIC code correctness
From: Scott Dattalo
Date: Sun, 28 Sep 2003 07:29:43 -0700 (PDT)

On Sat, 27 Sep 2003, Rick Mann wrote:

> Can someone please verify my assertion here?
> 
> (Scott, I sent this to you as well since you're the authority; I know 
> you don't have a lot of time for this, so please let me know if you'd 
> rather I didn't CC you on these).

You're right Rick, at the moment I don't have a lot of time for SDCC. I'm 
*still* working on a new gpsim release.

> 
> I have a C source file:
> 
> > #include "p16f877.h"
> >
> > void
> > main()
> > {
> > 	T0IE = 0;
> > 	OPTION_REG = 0x73;
> > 	
> > 	TMR0 = 217;
> > 	T0IF = 0;
> > 	while (T0IF == 0);
> > 	T0IF = 0;
> > }
> 
> If I compile this with the following command:
> 
> % sdcc -mpic14 -p16f877 -I /usr/share/gpasm/header/ turtle.c
> 
> It generates the following (incorrect) code:


As a general rule, I really don't trust SDCC with banked variables. Also, 
the only things in the PIC port that I know work are those that pass the 
regression tests in sdcc/src/regression/ . I don't trust anything else 
(and there's a whole lot of the 'else' stuff).

In this specific case, I think the option register and tmr0 are written to 
correctly. However, T0IF is a bit in the INTCON register. I'm not sure if 
the header file is correctly defining this bit or not. (From the looks of 
the code it isn't.)


Scott


gnupic@linuxhacker.org