Searching \ for '[PIC]: Quick Binary logic check' 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/microchip/devices.htm?key=pic
Search entire site for: 'Quick Binary logic check'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: Quick Binary logic check'
2002\12\19@202024 by Josh Koffman

flavicon
face
Hi, just want to get a quick check of my code. I think it will work, but
I want to be sure. Basically I want to take the lower 6 bits from PortA,
the 2 upper bits from PortB, and mask them together into one byte. Will
this work?
       movf    PORTA, W
       andlw   b'11111100'
       movwf   TEMP
       movf    PORTB, W
       andlw   b'00000011'
       iorwf   TEMP, F

I changed the name of my register to TEMP so it wouldn't be quite so
confusing.

Thanks!
Josh
--
A common mistake that people make when trying to design something
completely foolproof is to underestimate the ingenuity of complete
fools.
       -Douglas Adams

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

2002\12\19@221734 by Doug Hewett

flavicon
face
The 'lower 6 bits' should be b'00111111'
and the 'upper 2 bits' should be....

Your example code takes the upper 6 bits from PORTA inasmuchas it clears the lower 2 bits.

{Original Message removed}

2002\12\19@234901 by Josh Koffman

flavicon
face
Oops, good catch. That was my mistake in transcribing from the little
scrap of paper I was working this out on. Other than that, should my
routine work?

Josh
--
A common mistake that people make when trying to design something
completely foolproof is to underestimate the ingenuity of complete
fools.
       -Douglas Adams

Doug Hewett wrote:
{Quote hidden}

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

2002\12\20@094743 by Olin Lathrop

face picon face
> Hi, just want to get a quick check of my code. I think it will work, but
> I want to be sure. Basically I want to take the lower 6 bits from PortA,
> the 2 upper bits from PortB, and mask them together into one byte. Will
> this work?
>
>         movf    PORTA, W
>         andlw   b'11111100'
>         movwf   TEMP
>         movf    PORTB, W
>         andlw   b'00000011'
>         iorwf   TEMP, F

This merges the upper 6 bits of port A with the lower 2 bits of port B,
which is opposite of your description.  It also leaves the final value in
TEMP, not W, although that may be what you wanted.  Otherwise this is
correct assuming TEMP is in the same bank as PORTA and PORTB, and that the
bank is set correctly before this code segment.


*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

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