gnupic: gpasm: res and equates and bitfields
Subject:
gpasm: res and equates and bitfields
From:
Scott Dattalo ####@####.####
Date:
24 Mar 2004 05:34:32 +0000
Message-Id: <Pine.LNX.4.44.0403232111400.30764-100000@ruckus.brouhaha.com>
I probably should've sent this just to Craig, but maybe someone else has
an answer.
I was dabbling around in SDCC trying to figure out why bit variables are
no longer working. One of the problems is that if an 'EQU' directive
contains an expression with a reference to a relocatable object, then the
'first-pass' value is used for the relocatable object when the EQU is
evaluated. I'm not sure if that sentence makes sense, so here's an
example:
bitfield1 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
gpasm fails to assemble it correctly. The relocatable address used to
evaluate the EQU expressions is not correct.
I suspect this is not easy to fix in gpasm. I do not know if this
construct works with MPASM (I don't have convenient access to a Window's
machine with MPLAB installed).
I've used this technique many times for creating bit fields in
absolute-mode code. Does anyone know of a good way of creating bitfields
in relocatable code?
Scott