Searching \ for 'Oring bits within a byte' 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=oring+bits+within
Search entire site for: 'Oring bits within a byte'.

Truncated match.
PICList Thread
'Oring bits within a byte'
1998\01\26@110958 by Najemy, Daniel

flavicon
face
Good morning -

I'm trying to do the following:

I have a byte (let's call it TEMP), and I'm trying to logically 'OR'
together 3 of the bits within the byte.

ie. RESULT = (TEMP,3) or (TEMP,4) or (TEMP,5)

There doesn't seem to be any bit wise 'or' functions. Any ideas on how
to implement this?

Thanks in advance

Daniel Najemy -  Data General Corporation, Numaliine Power Systems

1998\01\26@120449 by Keith Howell

flavicon
face
Najemy, Daniel wrote:
>
> I have a byte (let's call it TEMP), and I'm trying to logically 'OR'
> together 3 of the bits within the byte.
>
> ie. RESULT = (TEMP,3) or (TEMP,4) or (TEMP,5)
>
> Any ideas on how to implement this?

       bcf     nResultByte, bResultBit ; assume result bit is zero
       movf    nTemp,W
       andlw   (1<<3 + 1<<4 + 1<< 5)   ; w := 00xyz0000
       btfss   STATUS,Z
       bsf     nResultByte, bResultBit ; sets result bit

I think this should do it.
If all the bits 3, 4 and 5 are zero, W := z,
the zero flag is set and the result bit is not

1998\01\26@120459 by Harold Hallikainen

picon face
On Mon, 26 Jan 1998 11:04:59 -0500 "Najemy, Daniel"
<spam_OUTDNajemyTakeThisOuTspamIMPS0014.US.DG.COM> writes:
>Good morning -
>
>I'm trying to do the following:
>
>I have a byte (let's call it TEMP), and I'm trying to logically 'OR'
>together 3 of the bits within the byte.
>
>ie. RESULT = (TEMP,3) or (TEMP,4) or (TEMP,5)
>


       How about something like this...

       movlw   b'0011100'      ; Set up the mask
       andwf   temp,0          ; Leave selected bits in w,
others 0
       bz      AllZeroes               ; go deal with them all being
zeroes
       ...                     ; Code to be executed if one or more
bits were set


Harold

_____________________________________________________________________
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com
Or call Juno at (800) 654-JUNO [654-5866]

1998\01\26@121859 by Kieran Sullivan

flavicon
face
Mask the three bits using AND. Test if resultant byte is 0 or greater than 0. If
it is greater than 0, then the result should be set to 1.

Kieran


----------
From:   Najemy, Daniel[SMTP:.....DNajemyKILLspamspam@spam@IMPS0014.US.DG.COM]
Sent:   26 January 1998 16:04
To:     PICLISTspamKILLspamMITVMA.MIT.EDU
Subject:        Oring bits within a byte

Good morning -

I'm trying to do the following:

I have a byte (let's call it TEMP), and I'm trying to logically 'OR'
together 3 of the bits within the byte.

ie. RESULT = (TEMP,3) or (TEMP,4) or (TEMP,5)

There doesn't seem to be any bit wise 'or' functions. Any ideas on how
to implement this?

Thanks in advance

Daniel Najemy -  Data General Corporation, Numaliine Power Systems

1998\01\26@121904 by sdattalo

face
flavicon
face
Najemy, Daniel wrote:
>
> Good morning -
>
> I'm trying to do the following:
>
> I have a byte (let's call it TEMP), and I'm trying to logically 'OR'
> together 3 of the bits within the byte.
>
> ie. RESULT = (TEMP,3) or (TEMP,4) or (TEMP,5)
>
> There doesn't seem to be any bit wise 'or' functions. Any ideas on how
> to implement this?

Yeah, we had this discussion a few months back.

Using the nomenclature then, here's a way to or two arbitrary bits in
two aribtrary registers and place the result in another arbitray
register: e.g. C.bit_C = A.bit_a | B.bit_b:

      BCF     C,bit_c
       BTFSS  A,bit_a
        BTFSC B,bit_b
         BSF  C,bit_c

Which could be extended for three or more bits.

However in your case, there's even a simpler trick:

     CLRF   RESULT        ;Assume all three bits are low

     MOVF   TEMP,W
     ANDLW  (1<<3) | (1<<4) | (1<<5)
     SKPZ
      INCF  RESULT        ;At least one bit was high

Scott
--
                                __o
 I buy pizza instead of gas.    \<
                             (*)/(*)

1998\01\26@121907 by Steve Lawther

flavicon
face
    Daniel,
   
    Best I can do of the top of my head is:-
   
       RLF     TEMP, W
       IORWF   TEMP, F
       RLF     TEMP, W
       IORWF   TEMP, F
   
    OR'ed result in TEMP,5
    Trashes TEMP and W
    4 cycles
   
    I'm sure somebody can do it better
   
               Steve Lawther
   
   


______________________________ Reply Separator _________________________________
Subject:      Oring bits within a byte
Author:  PC:.....DNajemyKILLspamspam.....IMPS0014.US.DG.COM at INTERNET-HUSKY
Date:    26/01/98 16:27


Good morning -
   
I'm trying to do the following:
   
I have a byte (let's call it TEMP), and I'm trying to logically 'OR'
together 3 of the bits within the byte.
   
ie. RESULT = (TEMP,3) or (TEMP,4) or (TEMP,5)
   
There doesn't seem to be any bit wise 'or' functions. Any ideas on how
to implement this?
   
Thanks in advance
   
Daniel Najemy -  Data General Corporation, Numaliine Power Systems
   

1998\01\26@123328 by sdattalo

face
flavicon
face
Steve Lawther wrote:
>
>      Daniel,
>
>      Best I can do of the top of my head is:-
>
>         RLF     TEMP, W
>         IORWF   TEMP, F
>         RLF     TEMP, W
>         IORWF   TEMP, F
>
>      OR'ed result in TEMP,5
>      Trashes TEMP and W
>      4 cycles
>
>      I'm sure somebody can do it better
>
>                 Steve Lawther

 Good idea Steve, but how 'bout:

       RLF    TEMP,W
       ANDLW  ((1<<3) | (1<<4) | (1<<5))<<1
       ADDLW  0xf0
       RLF    RESULT,F

Scott

1998\01\26@145403 by andre

flavicon
face
Najemy, Daniel wrote:

> Good morning -
>
> I'm trying to do the following:
>
> I have a byte (let's call it TEMP), and I'm trying to logically 'OR'
> together 3 of the bits within the byte.
>
> ie. RESULT = (TEMP,3) or (TEMP,4) or (TEMP,5)
>
> There doesn't seem to be any bit wise 'or' functions. Any ideas on how
> to implement this?
>
> Thanks in advance
>
> Daniel Najemy -  Data General Corporation, Numaliine Power Systems


if you are talking about doing or  with higher with lower nibbles this is
what you can do.

       cblock        00
       lower
       result
       endc

        movf          temp,w        ; temp is your byte        example
00001111
        swapf         temp,w          ;                         now temp
is    11110000
        movwf        lower            ; save swaped nibbles
        iorwf           temp,w            ; do or w with temp w is lower
and temp is higher
       movwf          result            ; save it in result
       movwf           portb            ; display the result on portb

   it is not tested  if this is what you need I can make it work and send
it to you.

Andre  Abelian





==========================================
= http://www.compufire.com               =
= EraseMEandrespam_OUTspamTakeThisOuTcompufire.com             =
= mcu-engineeringspamspam_OUTcompufire.com   =
= Andre Abelian: Engine Electronics, Inc.=
= Tel 909-589-5485  Fax 909-598-5695     =
==========================================

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