Thanks @avra. Your opinion and that of the others, really helps me on this project
.
USING SETS
=========
type
TStatusBits = (sbCX {0}, sbDC {1}, sbZ {2}, sbPD {3}, sbTO {4}, sbIRP = 7);
TStatusBitset = Bitset of TStatusBits;
var
STATUS [$03]: byte;
StatusBitset [@STATUS]: TStatusBitset;
I like the packed sets, but:
1. I see is too much code to define the bits of a a simple register (define the Elements of the set, define the set type, and define other variable of set type). I need to declare many registers (probably 100 or more ) for each device (probably 100 or more). That's why I'm looking for a simple declaration.
2. FAIK, when using sets, you can only work with fileds of one bit length. What about if I want a two-bits field?
3. When using sets, the syntax, to set or clear a bit, is complicated, in comparison with just: "STATUS.C := 1"
USING BIT POSITION
==============
const
Z: byte = 2;
var
STATUS [$03]: byte;
...
STATUS.Z := true;
I think this is the best approach for a simple bit manipulating (and it's how other compilers work).
But this way, define Z, like a global position, no only for STATUS.
I could do:
any_other_byte_variable_nothing_to_do_with_STATUS.Z := true;
So, it's not safe.