Adressing bit within loops

Hi Guys,
I am maninipulating 32 bits, obviously across 4 bytes.
I need to run something like;
Test:
B0 = 0
For counter1 = 1 to 6 '7bits
if bit[counter] = 0 then test2
bit[counet] = 1
Test2:next counter
From my reading theis is not possible, or have I missed something?
Gonzo
 

premelec

Senior Member
While not getting exactly what you want - note that w0 is 16 bits and can be loaded as b0 and b1 and bit0...bit15 can be accessed individually - or you can shift into bit15 by multiplying w0 * 2.... you get the idea?
 

inglewoodpete

Senior Member
The following code should do what you want:
<code><pre><font size=2 face='Courier'>
Symbol RAMPtr = b1
Symbol SampleByte = b2
Symbol BitPtr = b3
Symbol BitCtr = b4
Symbol Result = b5
'
For RAMPtr = 0 To 3 'Assume 4 bytes in 4 consecutive RAM locations
Peek RAMPtr, SampleByte 'Fetch a byte
BitPtr = %00000010 'Bit Pointer takes the form of a mask
For BitCtr = 1 to 6 'Process bits 1 to 6
Result = SampleByte And Mask
If Result &lt;&gt; 0 Then GoSub
BitPtr = BitPtr * 2 'Move mask bit up by 1 position
Next BitCtr
Next RAMPtr 'Get next byte
End
</font></pre></code>
You can copy the code by clicking on the edit icon, above. (Magnifying glass)

-Peter

Edited by - inglewoodpete on 27/07/2007 06:41:06
 
Top