On Mon, 30 Jun 1997 08:33:21 -0700 Scott Dattalo 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