Searching \ for 'AND how fast?' in subject line. ()
Help us get a faster server
FAQ page: www.piclist.com/techref/index.htm?key=how+fast
Search entire site for: 'AND how fast?'.

Truncated match.
'AND how fast?'
1997\09\02@151350 by

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
(*)/(*)
Scott Dattalo wrote:

> 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.

Not to mention it doesn't work. Jeeezz, it's difficult to right bad
code! What I meant was:

CLRW    0
BTFSC   A,bit_a
MOVLW  1
BTFSS   B,bit_b     ;Was BTFSC
CLRW
BCF     C,bit_c
IORLW   0
SKPZ
BSF    C,bit_c
On Tue, 2 Sep 1997, Scott Dattalo 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;

bsf   C,bit_c         ;assume the result will be high.
btfss A,bit_a         ;does bit_a make the result low?
bcf   C,bit_c         ;yes.
btfss B,bit_b         ;does bit_b make the result low?
bcf   C,bit_c         ;yes.

2+3+2+1=8 points if this works :)

-Shane.

{Quote hidden}

try this

bsf     c,bit_c
btfss   a,bit_a
bcf     c,bit_c
btfss   b,bit_b
bcf     c,bit_c

Correct me if I'm wrong, but I believe this one scores 8 good points.
{Quote hidden}

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:
{Quote hidden}

After further review:

bsf     c,bit_c
btfsc   a,bit_a
btfss   b,bit_b
bcf     c,bit_c

This one scores 10!

{Quote hidden}

Hi Shane (Shane Nelson), in <Pine.LNX.3.96.970902133152.20030y-100000cheetah.spots.ab.ca> on Sep 2 you wrote:

{Quote hidden}

You can save a cycle:

bsf  C,bit_c
btfsc        A,bit_a
btfss        B,bit_b
bcf  C,bit_c

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