> The following code will do a computed branch to any address in the > address space. > > MOVLW HIGH FARLABEL > MOVWF PCLATH > MOVLW LOW FARLABEL > ADDWF OFFSET,W > MOVWF PCL > . > . > . > > FARLABEL Not exactly. This assumes that LOW FARLABEL plus the contents of offset does not exceed 255. This is only guaranteed to be true if the table at FARLABEL starts at a 256 word boundary (FARLABEL is multiple of 256). A more general approach is: movlw high table ;get table start address high byte movwf pclath ;init jump address high byte movf offset, w ;get table entry number in W addlw low table ;make table entry address low byte skip_nc ;no carry into high address byte ? incf pclath ;propagate carry into high adr byte movwf pcl ;jump to the selected table entry This is the approach I recommend you always use except in rare cases where the few extra instructions matter for speed or memory size. Note that this code needs a slight tweak for the 18 family, since each instruction takes up 2 memory addresses, and GOTOs take up 4. > Another approach I have used is to put all of my lookup tables or > subroutines into specific pages, then if I need to do multiple accesses > I set the PCLATH register once at the beginning. That sort of manual management of PCLATH will sooner or later cause some nasty bugs. It is also a maintenence nightmare in the making. I use more automated PCLATH handling. See the GCALL and related macros in STD.INS.ASPIC at http://www.embedinc.com/pic. ***************************************************************** Embed Inc, embedded system specialists in Littleton Massachusetts (978) 742-9014, http://www.embedinc.com -- 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