gnupic: gpasm: res and equates and bitfields
Subject:
RE: gpasm: res and equates and bitfields
From:
Scott Dattalo ####@####.####
Date:
26 Mar 2004 14:31:12 +0000
Message-Id: <Pine.LNX.4.44.0403260608280.23056-100000@ruckus.brouhaha.com>
(ps. you're qmail setup doesn't properly demarcate your replies from the
quoted text.)
On the discussion of an alternative way for abstractly accessing
bitfields, scx31114 wrote:
> Try this
>
> bitfield0 res 1
> bitfield1 res 1
>
> _bit0 EQU 0
> _bit1 EQU 1
> _bit2 EQU 2
> ....
> _bit12 EQU 12
>
> to access the byte
> bitfield#v( (_bitN ) /8 )
>
> _bitN = _bit0 - _bit999
>
> to access the bit
> (_bitN%8)
> or
> (_bitN&7)
Yes, This works!
For SDCC, it makes sense to write code like:
BCF bitfield#v( (_bit4 ) /8 ), (_bit4 & 7)
MOVLW 1 << (_bit10 & 7)
XORWF bitfield#v( (_bit10 ) /8 ),F
For hand written assembly, it'd be nicer to write:
BCF bitfield(_bit4), (_bit4 & 7)
Where bitfield is defined to be:
#define bitfield(_bit) bitfield#v( (_bit ) /8 )
This doesn't work (with gpasm at least). As far as I can tell, gpasm
doesn't fully support the #define directive.
Scott