Hi Roger, RRF PORTB,W will not affect PORTB and will put the result into W. However, that result may not be exactly what you expect. RRF stands for Rotate Right File register. It is not the same as a right shift. The LSB gets placed into the carry bit (part of the status register) and the carry bit gets placed into the MSB of the result. So, in other words: Before the instruction: PORTB=3Dsome value W=3Ddon't care carry bit=3D0 or 1 After the instruction: PORTB=3Dunchanged W(bit 7)=3Dcarry bit value from before W(bits 6 through 0)=3DPORTB(bits 7 through 1) carry bit=3DPORTB(bit 0) Also, it seems a bit strange to me to perform an addition to the program counter like this. Do you really want to go to a unique piece of code for every single DIP switch setting? That's 16 different code snippets in this case. Sean On Mon, Sep 21, 2009 at 6:59 PM, Roger Weichert w= rote: > Hi Guys, > > I have a very basic question about the 'RRF' command, for a program using= a 16F627. > > I am using RB1,2,3,4 to read a DIP switch to choose 1 of 16 different out= comes. (RB0 is being used as an external interrupt otherwise it wouldn't be= a problem) > > I want to read the switch =A0... =A0'RRF' the result to scrub off the lea= st significant bit =A0... =A0then use that result (a number between 1 - 16 = ) to offset the program counter etc. > > I'm not sure of what I can 'operate' on =A0... > > Can I use =A0... > > =A0 =A0 =A0rrf =A0 =A0 =A0 =A0 =A0 portb,w =A0 =A0 =A0 =A0 =A0 =A0 ; remo= ve the least sig bit > > ... or does that mess with portb as well ... which has actual switches on= it. Then =A0... > > =A0 =A0 andlw =A0 =A0 =A0b'00001111' =A0 =A0 ; only keep the 4 lowest bits > =A0 =A0 addwf =A0 =A0 =A0pc,f =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ; add o= ffset to prog counter > > > ... =A0or do I have to read the port, move it into a seperate file regist= er .. =A0'RRF' that =A0... =A0 then move the result into 'w' to offset the = program counter ? > > ... =A0or alternatively, can I 'RRF' =A0'W' and put the result in 'W' ? > > I would have assumed the last one would be possible, but I cant find any = examples of it, so have been wondering. > > Thanks for any help. > > Regards, =A0 Roger > > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > -- = http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist