It seems to be working pretty well now, however when I use the rlf instruction the data is rolled into the high nibble of the variable temp and the carry never sees is. How can I make the temp variable four bits wide? Thanks for having mercy on such a newbi. Scott Tony Nixon wrote: > Scott wrote: > > > > Tony > > > > I did not expect to get a response so fast, thanks. However the > > code that you supplied executed in exactly the same way as my original > > code. It seems that when I rrf the a register the first bit is sent to the > > carry. When the instruction comes around a second time it again shifts the > > first bit into the carry instead of the second bit. > > > > Yes, that would be correct because you read PortA again and reloaded > 'Temp' with this data. > > However, if any switches are set, then the appropriate 'code_x' routine > will have executed before returning to the loop. I guess you have > appropriate code in these routines to handle debouncing, use switch once > and discard, or repeat, and to detect when it releases. > > It is best to read the port once to get the switch information, rather > than to use the 'rrf' instruction on it repeatedly. > > -- > Best regards > > Tony > > http://www.picnpoke.com > Email sales@picnpoke.com