Hi everybody,
color=#000000> 
color=#000000>        I'm a newby about PIC assembler and I'm currently developing a rather long program for PIC16F84 (at the moment it takes 3 pages of memory). After reading tons of info regarding PCLATH, page crossing and all the stuff related on how to handle the program counter I was confident to have the knowledge to manage the matter.
color=#000000> 
color=#000000>    Well, I was confident until I read a messagge in the PICLIST submitted two months ago by Jim Main in which he wrote :
color=#000000> 
<< ...
color=#000000> 
If you're in the second program memory code page when there's an
interrupt, then you jump back into page 1 to service the interrupt - the
relevant bit in PCLATH will still be set, so any CALLs or GOTOs in the
interrupt routine will jump down into the second page and get lost.

You just have to remember to save PCLATH in a temporary register, then
set for page 0 before doing any calls/gotos - then restoring pclath at
the end of the interrupt.

This caused me a lot of hairpulling when I had a big prog that jumped
round a lot - and it's not something you find in the Microchip docs..
 
color=#000000>...>>>>
color=#000000> 
  But this sounds strange to me as i learned reading Microchip's documentation the following facts:
color=#000000> 
1) the content of PC(12:8) is NEVER transferred to PCLATH;
color=#000000> 
2) the PC is 13 bits wide, so it can address up to 8K, but only the 2 most significant bits (12,11) come from PCLATH (4,3) when performing a CALL or GOTO instruction, the remaining 11 bits come directly from the opcode (the address which call or goto instruction is referring to);
color=#000000> 
3) the only case in which PCLATH imposes bits 8-12 of PC is when PCL (the lower 8 bits of PC) is the destination register in "normal" instructions (ie "movwf PCL", "addwf PCL", ... etc);
 
4) the entire 13bit address is pushed onto the stack when a call instruction is executed or interrupt is acknowledged and is furtherly popped at RETURN, RETLW or RETFIE.
color=#000000> 
Thus for all the chips with a program boundary under 2K (as 16F84 is), why to care for those stupid bits in PCLATH ? In Jim's case, if I have to perform a call or goto inside the int service routine, simply I can do it without the need of handling the bits in PCLATH and saving it for future restore. The call or goto instruction always jumps to the correct address and returning to the original address is guaranteed as well. I knew that care has to be taken only when performing computed goto in table read for page crossing handling.
color=#000000> 
color=#000000>    Am I missing something relevant with this issue ?
color=#000000> 
color=#000000>    Does anyone can help me to solve the mistery of long calls ?