I am in the middle of writing an interactive PIC disassembler, so, I think I got this one covered. org 0x00 bank 0 code org 0x800 code for bank 01 as for the calling, use the PCLATH register as follows : sample to call from bank 0 to bank 1 : ; ;-------------------------------------------------------- ; Program Bank 0 ;-------------------------------------------------------- ; ORG 0x0000 00:0000 $158A Reset BSF PCLATH, 3 <---- bit set for bank 1 00:0001 $2BCE GOTO L0BCEH from bank 1 to bank 0 : 01:0C11 $118A BCF PCLATH, 3 < --- bit clear is for bank 0 01:0C12 $2004 CALL L0004H ; 01:0C13 $158A BSF PCLATH, 3 <------- we are bank in bank 1 01:0C14 $3003 MOVLW 0x03 01:0C15 $1683 BSF STATUS, RP0 01:0C16 $00C1 MOVWF Page1_Addr41H I had to show off the code from my disassembler :) you do not have to worry about doing anything when returning. BUT, you must realize that PCLATH is not changed after returning. So, : from bank 1: bcf pclath, 3 <--- set pclath to bank 0 call somewhere_in_bank_0 call somewhere_in_bank_1 <==== this is an error! you must do a bsf PCLATH.3 before this or it will do a call to bank 0 hope it helps, kevin J FLETCHER wrote: > Hi all, > > I'm writing a program in MEL PicBasic for a programmable timer. It has a PIC16F876, a 20 x 2 LCD, a DS1307 RTC chip with coin cell backup, a relay and a four-switch keypad (up, down, next, back). When running it displays the time and day, and the next ON time (e.g. 12:30 Tomorrow). From the keypad I can change the time and day of week, and the ON time(s) and duration(s). The various parts of the program work OK, but the whole program is going to be between 2k and 4k long. Whenever the set of routines I'm testing exceeds 2k, things go wrong. I understand that the PIC program counter doesdn't automatically increment its highest bits. > > I think that I need to run code in the first 2k when the timer is just timing, and in the second 2k when an operator is changing the settings. Can anyone tell me (1) how to force some of the code to be compiled into the second 2k block and (2) how to cause the program to jump between blocks? Can this be done within the Basic code or do I have to edit the .ASM file somehow, perhaps using ORG? When writing the Basic code I don't know where the boundary is. I can only see this when it's compiled into a .HEX listing. > > Any advice greatly appreciated, this is really holding my project back. > > John Fletcher > -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist