> So I commented out the new code (subroutine) and it works again, BUT > if I comment out the code that calls the new subroutine (but leave the > subroutine in place), it still does NOT work. I've narrowed it down to the > existence of the code that causes a problem. I've even changed the new > subroutine to 26 nop's (instead of the 26 instructions that were there) with > absolutely no calls to it, and it still fails. > > So now I look at page boundaries, but my total code size is under 600 > bytes, and I should not have to worry about paging on a 2K-prog-memory > 'F872. Another check for tables crossing the 256-byte boundary and no > violations there. Also using indirect addressing in various places, but > all addresses pointed to are in bank 0 of data mem so that should not > be a problem. Obviously this bug has something to do with code moving around in memory. Here are a few possible causes of the bug: 1 - PCLATH is incorrect when you jump into a table. PCLATH can be ignored for the purpose of paging because all your code is on a single page. This is because the GOTO and CALL instruction supply 11 bits of the address, and PCLATH is only used for the remaining upper two bits - which aren't used on the '872 anyway. However, when PCL is modified directly, then PCLATH supplies all but the low 8 bits of the target address. If a table doesn't cross a 256 word boundary, then the same PCLATH value can be used for all table entries, and it can therefore be explicilty loaded with the appropriate constant. It does NOT mean that PCLATH can be simply ignored. 2 - You have a bug in either case that causes a jump to an invalid location. The additional code moves things around so that a different section of your code gets jumped to. The previous one happened to cover up the bug, the new one doesn't. Either way this should be easy to find with the emulator, ICD, or perhaps even the simulator. The PIClist is not a substitute for either of these. You should do all reasonable homework (debugging with ICE, ICD, or SIM is certainly part of this) before asking 2000 people to take time out to do you a favor. ***************************************************************** 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