PDA

View Full Version : Help with bit array



Dick M
- 27th August 2006, 15:06
I need help defining a word variable that I can access as a word, the high and low byte and as a bit array? I need to point to the a bit in the word with a for next loop. I know how to dfine a bit array. mybitarray var bit[16] but how do I access the word and the low and hi byte of the bit array. I know that you can access bits of a word like myWord.7 but how do I change the .7 in a for next loop?

Dave
- 27th August 2006, 17:26
Dick M,All you need to do is setup an INDEX counter as I have done here. The counter can count from 0 to a maximum of 255 so to use this type of indexing your array of bits can not be any bigger than 255 which equals 32 BYTES or 16 WORDS. You then index into the array of BYTES or WORDS like so:

INDEX VAR BYTE
ARRAYBYTE VAR BYTE[2] 'USE BYTE ARRAY IF CONVIENIENT or
ARRAYBYTE VAR WORD 'THIS WILL ALLOW 2 BYTES or 16 BITS OF DATA

FOR INDEX = 0 TO 15 'INCREMENT THRU ALL 16 BITS
ARRAYBYTE.0(INDEX) = 1 'GIVE BIT SOME VALUE
NEXT 'INCREMENT INDEX

Dave Purola,
N8NTA

Dick M
- 27th August 2006, 17:31
Thanks for the help Dave that was what I was looking for.