>As I said, I've used RETLW many times and never struck this >problem, so I must have been lucky. Although having said >that, if I had I'd have worked it out then instead of now. Well you must have been real lucky if you ignored all the recommendations given in the app note on doing these tables. Let us just examine your code for a moment :) >But this adds W to PCL and returns immediately to 00xx, not >to 01E8 > >01E2 movwf devno > call bitnum >01E8 movwf temp >01EA bra cp_num > >0204 bitnum > addwf pcl > retlw 0x01 > retlw 0x02 > etc Your code is crossing a 256 byte page boundary - not a problem in itself provided the correct labels are used when calculating the offset into the table, rather than using movlw high $ ; potential to get 0x01 instead of correct 0x02 if crossing page boundary ; needs to be "movlw high bitnum+1 movwf pclath ; ready for computed jump and then as others have pointed out there is no code to load PCLATH at all. Based on this (assuming PCLATH is 0x00 as appears to be the case from what you post) your code is going to go to 0x0005 + W instead of 0x0205 + W >As the code is still evolving I'll be ditching the RETLW in >favour of TBLPTR Why, adding two lines of code in accordance with the app note on doing things this way will bring it all correct. To make sure that I get the correct high byte of the address to put into PCLATH I always use a label after the "addwf pcl" instruction to allow for crossing the page boundaries. The other trick of course is to make sure your W is always even, as someone else pointed out. This is real easy seeing you are saving the W reg anyway. My reckoning is that the code will then be as follows :- movwf devno movlw high bitnum_table movwf pclath movf devno,w ; addwf devno,w ; only needed if we do not know w is always even ; btfsc status,c ; ditto ; incf pclath,f ; - inc pclath if doubled W is >255 call bitnum movwf temp bra cp_num bitnum addwf pcl bitnum_table retlw 0x01 retlw 0x02 ; etc -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics