> >No, no, no! You have to worry about PCLATH whenever you do a CALL or GOTO > >to a location that could be on a different page. After a subroutine > >returns, PCLATH is set the way the subroutine left it, which is usually > >pointing to its page. This can mess up GOTOs that otherwise go to > >addresses > >known to be on the same page. > > This is odd because I have programs that call subroutines at the very end of > a 2K PIC from the ISR routine at ORG 4 with no trouble. I don't save PCLATH > and never adjust it in the program. The only trouble I run into is when I > do a computed GOTO jump, in which case I set the PCLATH manually. > > If your statement is true, I'd never be able to return to nearly 80% of my > calls, since they run the gamut of program memory locations from 0x00A > through 0x700. Yet I have no problems. Not odd at all because everything you mention is within the first code page, from 0 to 7FF. You won't get away with ignoring PCLATH if your code is on multiple pages. You will also have to save/set/restore PCLATH in the interrupt routine if you do any GOTOs or CALLs in it anywhere. ***************************************************************** Olin Lathrop, embedded systems consultant in Devens Massachusetts (978) 772-3129, olin@embedinc.com, http://www.embedinc.com -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.