Truncated match.
PICList
Thread
'Oring bits within a byte'
1998\01\26@110958
by
Najemy, Daniel
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
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
On Mon, 26 Jan 1998 11:04:59 -0500 "Najemy, Daniel"
<spam_OUTDNajemyTakeThisOuT
IMPS0014.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
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:.....DNajemyKILLspam
@spam@IMPS0014.US.DG.COM]
Sent: 26 January 1998 16:04
To: PICLIST
KILLspamMITVMA.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
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
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:.....DNajemyKILLspam
.....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
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
|
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_OUT
TakeThisOuTcompufire.com =
= mcu-engineering
spam_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...