Fast bitwise AND? How many points for: bcf C, bit_c btfss A, bit_a goto BitwiseAndEnd: btfss B, bit_b goto BitwiseAndEnd: bsf C, bit_c BitwiseAndEnd: -Ed VanderPloeg. At 12:22 PM 9/2/97 -0800, you wrote: > >How fast can you logically AND two bits? > >Given: > bit_a of register A > bit_b of register B > bit_c of register C > >The goal in C parlance is: > > C.bit_c = A.bit_a & B.bot_b; > > >And just so it's clear, here's some sluggish PIC code that does >the job: > > CLRW > BTFSC A,bit_a > MOVLW 1 > BTFSC B,bit_b > CLRW > BCF C,bit_c > IORLW 0 > SKPZ > BSF C,bit_c > >9 unbearably long cycles and trashes W. Last week I placed too much >emphasis on preserving W. This week the emphasis is on speeeed. > >So here are how the points are to be tallied: > > 1) Size: 2*(6 - # of execution cycles) > 2) Isosynchonous: 3 points > 3) Preserves W: 2 points > 4) Preserves reg A and B: 1 point > >The example slug scores: 2*(6-9) + 3 + 0 + 1 = -2 > >My pre-Payson/Keitz solution is worth 10 points. >hint: x & y = ~(~x | ~y) > > >Scott >-- > __o > I still buy pizza instead of gas. \< > (*)/(*) > > >