At 13:46 1998-10-27 -0600, John Payson wrote: >>Table read has to be made with a jump/call table. (With chips >>like 16x84 or 12c50x) This is simple when page boundries are >>not crossed. With non-relocatable code it is simple in that >>case as well. (Covered well in the Microchip AppNotes) > -snip- > >I think you could probably do something like: > > ;movwf TableOffset,w ; If needed... > movlw HIGH TableStart > movwf PCLATH > movlw LOW TableStart ; Find out the state of the carry flag > addwf TableOffset,w > btfsc C > incf PCLATH > movwf PCL > >Pretty annoying code, though I can't think of anything more versatile. But to minimize size and time, we can just let the *compiler* check if the table crosses a page boundary, and if so warn us. I use this style: adtable: VARIABLE tablestart = $ ; <-- REMEMBER BEGINNING addwf PCL,F retlw b'00000010' ; our table... ;etc... retlw b'10010010' IF high $ != high adtable ;<-- COMPARE HIGH BYTE OF START WITH HIG H BYTE OF END ERROR "addwf PCL overflow in table!" ENDIF So, if we get this error, we either relocate the table, or add Johns code for run-time method solution above. It would have been wonderful if we could have a way to set a variable and then trigger a second pass for the compiler. Then we could make some kind of automated selection of what to compile, based on earlier compile pass errors. (A whish for next MPLAB) /Morgan Morgan Olsson ph +46(0)414 70741 MORGANS REGLERTEKNIK fax +46(0)414 70331 H€LLEKS (in A-Z letters: "HALLEKAS") SE-277 35 KIVIK, SWEDEN mrt@iname.com ______________________________________________________________