>isnt that a macro? >im using pic16f877(self programming). >the chip will be programming this into itself, so macros wont work. >i dont understand how it could work. if you wanted to switch to, say, >address 0 of page0, i would need to clrf pclath, then i would need to clrf >pcl. wouldnt clearing pclath modify the program counter and before i could >move to to address 0. Use CALL, not GOTO instruction. Call performs a 'GOSUB' within 2kW page without additional care. A RETURN instruction at the end of the subroutine makes your program to continue at the next instruction after the CALL instruction. On PIC16F877 you have four program pages 2kW each. To call subroutine in different page, you only need to update bits 3 and 4 of PCLATH before executint the CALL instruction. The RETURN is again at the correct line after the CALL, but PCLATH is not changed. Example: ORG 0 ; page 0 INIT: .... MAIN: BSF PCLATH,3 CALL SUB1 ; calling subroutine in page 1 from page 0 BCF PCLATH,3 ... ... BSF PCLATH,4 CALL SUB2 ; calling subroutine in page 2 from page 0 BCF PCLATH,4 .... GOTO MAIN ORG 0x800 ; page 1 SUB1: ... ... RETURN ORG 0x1000 ; page 2 SUB2: ... BSF PCLATH,3 BCF PCLATH,4 CALL SUB1 ; calling subroutine in page 1 from page 2 BCF PCLATH,3 BSF PCLATH,4 ... RETURN Josef -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist