Searching \ for 'Bit arrays' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/index.htm?key=bit+arrays
Search entire site for: 'Bit arrays'.

Truncated match.
PICList Thread
'Bit arrays'
1997\03\07@003924 by Ed Todd

picon face
Define a bit array table: just values, no storage
FIRSTBIT        EQU     0
SECOND          EQU     3


TWENTIETH       EQU     .20

Define storage for array

BITFLAGS   EQU    START
BITFALGS1 EQU    START+1


Write some macros, such as:

IFBITON         MACRO           A
BMV1            SET             A/8
BMV2            SET             A-(8*BMV1)
                       BTFSC           BITFLAGS+BMV1,BMV2     ; do next if bit
is set
               ENDM

               IFBITON TWENTIETH
will generate a BTFSC   BITFLAGS+2,4

I find this very helpful: I don't have to remember which byte a particular
flag is in, I just need the flag name.

1997\03\07@081036 by Andrew Warren

face
flavicon
face
Ed Todd <spam_OUTPICLISTTakeThisOuTspamMITVMA.MIT.EDU> wrote:

> Write some macros, such as:
>
> IFBITON         MACRO           A
> BMV1            SET             A/8
> BMV2            SET             A-(8*BMV1)
>                 BTFSC           BITFLAGS+BMV1,BMV2     ; do
>                         next if bit is set
>                 ENDM
>
>                 IFBITON TWENTIETH
> will generate a BTFSC   BITFLAGS+2,4
>
> I find this very helpful: I don't have to remember which byte a
> particular flag is in, I just need the flag name.

Ed:

This isn't EXACTLY the same thing, but MPASM already supports
single symbols for register/bit combinations:

   #DEFINE  TWENTIETH BITFLAGS3,3
   ....
            BTFSC    TWENTIETH

-Andy

=== Andrew Warren - .....fastfwdKILLspamspam@spam@ix.netcom.com
=== Fast Forward Engineering - Vista, California
===
=== Custodian of the PICLIST Fund -- For more info, see:
=== www.geocities.com/SiliconValley/2499/fund.html


'Bit Arrays'
1997\05\15@222330 by Carter Brock
flavicon
face
The problem is I have 76 bits in 8 consecutive bytes that have been
interleaved in the following pattern:

(1,20,39,58,2,21,40,59....)

Now if there was such an animal in the PIC world as a bit array, code that
looked something like this would do it:

for (i=0;i<20,i++) {
 for(j=0;j<3;j++) {
   deinterleaved_array[k++]=interleaved_array[(j*19)+i];
 }
}

Any suggestions on the best way of testing, setting and clearing bits in an
array of bytes?

                       TIA,

                               Carter Brock

1997\05\16@104107 by Dmitry Kiryashov

flavicon
face
Carter Brock wrote:

> The problem is I have 76 bits in 8 consecutive bytes that have been
> interleaved in the following pattern:

It's real big problem because 76 bits overflow 8 bytes ;)
I think you are talk about 9.5 bytes ?

> (1,20,39,58,2,21,40,59....)
So you have sequence above and you need to rearrange it
to 1,2,3,4,5,....,73,74,75,76 ?

I think it will be easy read bit by bit sequency from input
to fill 4 3-bytes arrays like example below .

; bytes A0 | A1 | A2 = x,x,x,x,x,1,2,3 | 4,5,6,7,8,9,10,11 |
12,13,14,15,16,17,18,19
; B0 | B1 | B2 = x,x,x,x,x,20,21,22 | 23,24,25,26,27,28,29,30 |
31,32,33,34,35,36,37,38
; C0 | C1 | C2 = x,x,x,x,x,39,40,41 | 42,43,44,45,46,47,48,49 |
50,51,52,53,54,55,56,57
; D0 | D1 | D2 = x,x,x,x,x,58,59,60 | 61,62,63,64,65,66,67,68 |
69,70,71,72,73,74,75,76

;Let suppose you read from port PORT from input pin with number IN_BIT

PORT    EQU     PORTC
IN_BIT  EQU     5       ;PORTC.5

       MOVLW   D'19'
       MOVWF   COUNT

READ_LOOP:
       MOVFW   PORT,IN_BIT     ;copy IN_BIT to Carry
       ANDLW   (1<<IN_BIT)
       ADDWF   ~(1<<IN_BIT)+1
       RLF     A2              ;shift Carry to A
       RLF     A1
       RLF     A0

       MOVFW   PORT,IN_BIT     ;read IN_BIT to Carry
       ANDLW   (1<<IN_BIT)
       ADDWF   ~(1<<IN_BIT)+1
       RLF     B2              ;shift Carry to B
       RLF     B1
       RLF     B0

....
....
;       Also read to C0,C1,C2 and D0,D1,D2
....
....
       DECFSZ  COUNT
       GOTO    READ_LOOP



> Now if there was such an animal in the PIC world as a bit array, code that
> looked something like this would do it:
>
> for (i=0;i<20,i++) {
>   for(j=0;j<3;j++) {
>     deinterleaved_array[k++]=interleaved_array[(j*19)+i];

?????                                             ^^^^
     deinterleaved_array[k++]=interleaved_array[(j*4)+i];

{Quote hidden}

WBR Dmitry.

More... (looser matching)
- Last day of these posts
- In 1997 , 1998 only
- Today
- New search...