michael brown wrote: > wouter van ooijen wrote: > >>>> Note that this code still requires that all jump table >>>> >>> entries are in >>> >>>> the same 256-instructions page. For a jumptable that crosses a page >>>> boundary (hence for all >256 entries tables) you will have to >>>> calculate the value to load into PCLATH. >>>> >>> Unless I'm really missing something here, I don't understand >>> why you say >>> that. His technique takes into consideration that a page is being >>> crossed and appropriately increments PCLATH by 1 when that is >>> happening. >>> >> Sorry, you are right. I did not look well enough. >> You ave anymore got a point: the jump table must be less than 256 byte... I have not considered this... Bigger tables needs a little more complex code but I think that is not the case of the OP > > I don't know why Microchip doesn't tout doing it this way. It's only a > few instructions more and makes the table floatable. Here is how I > did it for a character table on a 16F88: > > get_msg_char > movfw msg_ptr ; get desired offset from beginning of string > btfss PORTA, DIRECTION ; Check direction > sublw message_size - 1 ; When going CCW, we must fetch letters in reverse order > addlw 3 > addwf PCL, W ; Add offset and current PCL > skpnc ; Check for page crossing > incf PCLATH, F ; and compensate for it > movwf PCL ; Fetch the value > message dt "MESSAGE TEXT GOES HERE" > message_size equ $ - message > > I intentionally forced the text to cross a page boundary and all was > well. The 3 being added is for the skpnc, incf and movwf instructions. > > Your code works but i dont like it: the ADDLW 3 is in the category of dangeours tricks :-) just reordering the instructions you can eliminate it and have a more readable code -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist