Need some code help and or suggestions with buffer indexing
Don M
Posts: 1,652
I have a 27 byte main buffer but I'm only concerned about the last 16 bytes (from byte 26 to byte 11 in that order). Let's say that bytes 26 through 11 contains the following:
Byte 26 >>>>>>>>>>>>>>>>>>>>>>> Byte 11
00 00 00 00 00 00 00 00 00 00 FF 14 0A 05 02 01
Now I have another buffer that has 2 bytes. We'll call it the mask buffer. It is a mask for which of the 16 bytes from the main buffer will be displayed.
Let's say I only want to display bytes 11, 13, 14 & 15 of the main buffer so the mask buffer would be:
Hex: $1D
Binary:
bit15 >>>>>>>> bit 0
0000 0000 0001 1101
How do I make this work?
Byte 26 >>>>>>>>>>>>>>>>>>>>>>> Byte 11
00 00 00 00 00 00 00 00 00 00 FF 14 0A 05 02 01
Now I have another buffer that has 2 bytes. We'll call it the mask buffer. It is a mask for which of the 16 bytes from the main buffer will be displayed.
Let's say I only want to display bytes 11, 13, 14 & 15 of the main buffer so the mask buffer would be:
Hex: $1D
Binary:
bit15 >>>>>>>> bit 0
0000 0000 0001 1101
How do I make this work?
Comments
Repeat the following 16 times
Test the MSbit of the mask
If the bit is 1 display the byte pointed to
shift the mask left 1
decrement the byte pointer
Repeat the following 16 times
Test the MSbit of the mask
If the bit is 1 display the byte pointed to
shift the mask left 1
decrement the byte pointer
I was trying to do this just to display which bits are set in the buffer but I get an error trying to compile. It doesn't like the |<.
What am I doing wrong here?
Still wondering why Prop tool didn't like the |< expression....
Ok with that here is what I tried:
"mask" has the value of $1D (0000 0000 0001 1101)
For the response I get: 0 0 0 0 0 0 0 0 0 0 0 16 8 4 0 1
I thought I would have gotten: 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 1
How do I change it to get that type of response?
Thanks again for your help. Much appreciated.