Peter (again),

Something to think about until I get back to you tomorrow.

A set of flags Flag1, Flag2, . . . , Flag8 can be viewed as an array

f(1)          f(2)                   f(8)
|                |                |       |
|bbbbbbbb|bbbbbbbb| . . . |bbbbbbbb|

in each element of which the eight bit positions are labeled

|b b b b b b b b|
 1 2 3 4 5 6 7 8

If then 0 < i <= 8 is a byte subscript and 0 < j <= 8 is a bit
subscript in some byte j can also be used to subscript an array of 8
masks

mask(1), BL1'10000000'
mask(2), BL1'01000000'
mask(3), BL1'00100000'
mask(4), BL1'00010000'
mask(5), BL1'00001000'
mask(6), BL1'00000100'
mask(7), BL1'00000010'
mask(8), BL1'00000001'

usable to test any bit position in any byte-array element.

If then having put flag names in ascending lexicographic sequence the
position p of a flag name in this (also one-origin) sequence
determines both i and j.  We have

i =  floor[p/8] + 1
j = mod(p,8) + 1

The construction of a one-origin lexicographically ordered sequence of
flag names is thus the only really interesting task here.

John Gilmore, Ashland, MA 01721 - USA

Reply via email to