gnupic: Bit variables in C


Previous by date: 15 Nov 2000 13:30:33 -0000 Re: Bit variables in C, David Kott
Next by date: 15 Nov 2000 13:30:33 -0000 Re: Bit variables in C, Ian Stedman
Previous in thread: 15 Nov 2000 13:30:33 -0000 Re: Bit variables in C, David Kott
Next in thread: 15 Nov 2000 13:30:33 -0000 Re: Bit variables in C, Ian Stedman

Subject: Re: Bit variables in C
From: Scott Dattalo ####@####.####
Date: 15 Nov 2000 13:30:33 -0000
Message-Id: <Pine.LNX.4.21.0011150730580.18530-100000@tempest2.blackhat.net>


On Wed, 15 Nov 2000, Scott Dattalo wrote:

> On Wed, 15 Nov 2000, Alex Holden wrote:
> 
> 
> >                One problem, how do you represent a pointer to a single bit
> > variable?
> 
> That's a good question. The short answer is I don't know (at least
> efficiently). 

After I wrote this, I tried bit pointers with SDCC. It says:

t.c(21):error *** Array or Pointer to bit|sbit|sfr not allowed.'Pbit'

There, Problem solved!

The PIC code SDCC generates for bit addition is:

bit bit0 = 0;
bit bit1 = 0;
bit bit2 = 0;

  bit1 = bit0 + bit2;  // t.c line 25

;       t.c 25
        movlw   (1 << (_bit1 & 7))
        bcf     (_bit1 >> 3), (_bit1 & 7)
        btfsc   (_bit0 >> 3), (_bit0 & 7)
        xorwf   _bit1,f
        btfsc   (_bit2 >> 3), (_bit2 & 7)
        xorwf   _bit1,f

BTW, I posted a challenge to the PICLIST to minimize this snippit. I'm probably
going to be posting many little challenges like this.


SDCC `bit' types will be supported in the PIC port of SDCC.

Scott


Previous by date: 15 Nov 2000 13:30:33 -0000 Re: Bit variables in C, David Kott
Next by date: 15 Nov 2000 13:30:33 -0000 Re: Bit variables in C, Ian Stedman
Previous in thread: 15 Nov 2000 13:30:33 -0000 Re: Bit variables in C, David Kott
Next in thread: 15 Nov 2000 13:30:33 -0000 Re: Bit variables in C, Ian Stedman


Powered by ezmlm-browse 0.20.