> > I did some sim-debugging and had to find out, that RETLW > is not restoring PCLATH correctly after returning from the > computed goto. > > A normal RETURN does :-( > > > > > You are wrong. The datalist is not so clear but the PCLATH is > NEVER restored by a return. > If you want to call a subroutine in another page: > PAGESEL MySub ;PAGESEL is an internal MPASM > macro that load the correct value > call MySub > PAGESEL CurrentPage ;the choice of CurrentPage is > important! I was not sure, if a RETURN restores the PCLATH, but all the doc's I found in the web said, it does. I made a small sample code for a 16F877A, jumping between the pages all over the 8Kbyte ROM. I used the ICD2 on real hardware with MPLAB7.50 and also the Software Simulator in 7.50. And ... after the RETURN, the PCLATH was restored to the value, the CALL was made from ... But only with a RETURN. RETLW was not restoring, but RETLW is the one to use for tables ... And, the datasheet is absolute clear about the PC stack: This is from the 16F877A datasheet: 2.3.2 STACK The PIC16F87XA family has an 8-level deep x 13-bit wide hardware stack. The stack space is not part of either program or data space and the stack pointer is not readable or writable. The PC is PUSHed onto the stack when a CALL instruction is executed, or an interrupt causes a branch. The stack is POP'ed in the event of a RETURN, RETLW or a RETFIE instruction execution. PCLATH is not affected by a PUSH or POP operation. That means, that a RETURN, RETLW and RETFIE will cause a POP of PC (= PCLATH and PCL) back to where the CALL was made from, or? Best Jens -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist