Searching \ for 'RRF and Port values' 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/ios.htm?key=port
Search entire site for: 'RRF and Port values'.

Truncated match.
PICList Thread
'RRF and Port values'
1997\06\28@144907 by ndod

picon face
I have a challange, that without using an additional memory location I
cannot solve.
       I have 5 pins on port C on a 16c73a that are hooked to a set of jumper
plugs.
       Pins 0, 1 are read correctly
       Pins 4,3,2 are needed to shift right 2 positions for a table bias

       so the code is:
               MOV     PORTC,W
               RRF     W,1
               RRF     W,1

       However this gives erroneous results, and coding as
               MOV     PORTC,W
               RRF     W,0
               RRF     W,0
       gives really weird results.


       I just want to shift the values in PORTC 2 bits right. Any ideas????

       It does seem the RRF    W,either value should be valid, I could find not
hing
to the contrary in the specs, and would be useful. How should something
like this be implemented?

Kevin E. Dodd
Embedded Systems Consulting
2601 NE Jack London #49
Corvallis, Oregon, 97330
spam_OUTkevindodTakeThisOuTspamcyberhighway.net
541.753.3633

1997\06\28@153248 by Site Y

picon face
>Kevin E. Dodd wrote:

>  Pins 4,3,2 are needed to shift right 2 positions for a table bias
>
>        so the code is:
>                MOV     PORTC,W
>                RRF     W,1
>                RRF     W,1
>
>        However this gives erroneous results, and coding as
>                MOV     PORTC,W
>                RRF     W,0
>                RRF     W,0
>        gives really weird results.

Kevin,
 You can't shift the W register in a '73.   The weird results may be
caused by W equating to 0 in
your assembler.  Then the register you are actually operating on is the
Indirect register...

 You need some kind of intermediate register to do what you want, for
instance:

       RRF     PORTC,W
       MOVWF   TEMP
       RRF     TEMP

Hope this helps,
 Marv

1997\06\30@113330 by sdattalo

face
flavicon
face
Kevin Dodd wrote:
>
> I have a challange, that without using an additional memory location I
> cannot solve.

>         Pins 4,3,2 are needed to shift right 2 positions for a table bias

Try this:

       MOVLW   0
       BTFSC   PORTC,2
        IORLW  1
       BTFSC   PORTC,3
        IORLW  2
       BTFSC   PORTC,4
        IORLW  4

Scott
--
"The problem with television is not the resolution."
                                Hugh. F. Frohbach

1997\06\30@122342 by Mike Keitz

picon face
On Mon, 30 Jun 1997 08:33:21 -0700 Scott Dattalo <.....sdattaloKILLspamspam@spam@unix.SRI.COM>
writes:
>Kevin Dodd wrote:
>>
>> I have a challange, that without using an additional memory location
>I
>> cannot solve.
>
>>         Pins 4,3,2 are needed to shift right 2 positions for a table
>bias
>
>Try this:
>
>        MOVLW   0
>        BTFSC   PORTC,2
>         IORLW  1
>        BTFSC   PORTC,3
>         IORLW  2
>        BTFSC   PORTC,4
>         IORLW  4

Since the result will be used for table access, it isn't necessary to
preserve the bit order, just make the low 3 bits of W one to one
correspond with the switch inputs.  How about:
       rrf     PORTC,w         ;Port = xxxCBAxx.  Get W =
xxxxCBAx
       andlw   b'00000110'     ;Now  00000BA0
       btfsc   PORTC,4         ;Is C = 1?
       iorlw   b'00000001'     ;Yes, it is.
;W now 00000BAC.  Rearrange the table to account for MSB last.

If speed is more important than code space, make each table entry 2
instructions long and just use a single rotate into W and andlw to get
0000CBA0.  The extra bytes interleaved with the table could be used as
another table by computing an index of 0000CBA1.

Of course, the traditional method requires a RAM location to rotate twice
and is still 4 instructions:
       rrf     PORTC,w         ;Port = xxxCBAxx.  Get W =
xxxxCBAx
       movwf   tmp             ; tmp = xxxxCBAx
       rrf     tmp,w           ;W=xxxxxCBA
       andlw   b'00000111'     ;W=00000CBA

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