Hi Bob. Here is mystical 12 again. Not tested, as is. ;00/01/10/11 -> oooooo11/oooo11oo/oo11oooo/11oooooo ;position by switch.10 -> pattern by mask.10 -> result ;a_bit, b_bit bits located somewhere movlw 0x03 ;oooooo11 btfsc switch,bit0 movlw 0x0C ;oooo11oo movwf temp btfsc switch,bit1 swapf temp,W ;oo11oooo/11oooooo iorwf result,F ;xxxxxx11 | xxxx11xx | xx11xxxx | 11xxxxxx btfsc mask,bit1 andlw 0x55 ;a_bit -> 01010101 -> result.bit1 = preserved btfsc mask,bit0 andlw 0xAA ;b_bit -> 10101010 -> result.bit0 = preserved xorwf result,F WBR Dmitry. Bob Ammerman wrote: > > Eight, eight, I have eight. Do I hear seven...?? > > Bob Ammerman > RAm Systems > > ----- Original Message ----- > From: "Dmitriy A. Kiryashov" > To: > Sent: Friday, July 19, 2002 2:18 PM > Subject: Re: [PIC]: Code optimization > > > Hi Scott. > > > > #define ab b'01010101 > > > > movlw 0x03 ;oooooo11 > > btfsc num,0 > > movlw 0x0C ;oooo11oo > > btfsc num,1 > > movlw 0x30 ;0011oooo > > > > iorwf var,F ;xxxxxx11 | xxxx11xx | xx11xxxx > > andlw ~ab ;00000010 | 00001000 | 00100000 > > xorwf var,F > > > > WBR Dmitry. > > > > > damn. > > > > > > #define _ABABABAB b'01010101 ; or whatever > > > > > > movlw 0xfc ; bit 0,1 are low > > > > > > btfsc number,0 ; LSB set? > > > movlw 0xf3 ; bit 2,3 are low > > > btfsc number,1 ; Bit 1 set? > > > movlw 0xcf ; bit 4,5 are low > > > > > > ; write the _AB_ bit pattern > > > andwf var,f ; clear the dest bits > > > xorlw 0xff ; complement the bit mask > > > andlw _ABABABAB ; select the two desired AB's > > > iorwf var,f ; write them -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads