gnupic: gpasm: res and equates and bitfields
Subject:
RE: gpasm: res and equates and bitfields
From:
Scott Dattalo ####@####.####
Date:
25 Mar 2004 04:07:09 +0000
Message-Id: <Pine.LNX.4.44.0403241948420.22511-100000@ruckus.brouhaha.com>
On Wed, 24 Mar 2004, scx31114 wrote:
actually I wrote this part:
> bitfield0 res 1
>
> _bit0 EQU ( (bitfield0<<3)+0)
> _bit1 EQU ( (bitfield0<<3)+1)
> _bit2 EQU ( (bitfield0<<3)+2)
>
>
> The idea is that an array of named bits is created and aliased onto the
> byte reserved by the bitfield.
>
>
> Now, if you write code to access the bits:
>
> bcf _bit0 >> 3, _bit0 & 7
>
And scx31114 wrote this part:
> one possible solution
>
> bitfield0 res 1
>
> #define _bit0 bitfield0,0
> #define _bit1 bitfield0,1
> #define _bit2 bitfield0,2
>
> Now, if you write code to access the bits:
>
> bcf _bit0
Well, that does work for the simple case. However, how about this:
; bit add
bcf _bit0 >> 3, _bit0 & 7
movlw (1 << (_bit0 & 7)
btfsc _bit1 >> 3, _bit1 & 7
xorwf (_bit0 >> 3),f
btfsc _bit2 >> 3, _bit2 & 7
xorwf (_bit0 >> 3),f
Here, the bit is being accessed both as a bit and as a 'byte'.
What I really would like is a way of defining a single object to describe
the bit variable. The only solution that I can think of for relocatable
code requires two objects to describe a bit variable. You need to know the
address of the byte containing the bit and the offeset within the byte.
The byte can be relocated, but the offset is static.
Scott