> In my program I am using the program counter to sequence several routines. I > am using it like this: > > MOVF SSTATE,W > MOVWF PCL Recall that the lower 5 bits of 'PCLATH' are concatenated to PCL for a computed goto such as this. > > SSTATE is the address of the specific routine. My problem is SSTATE is an 8 > bit value and my routine length goes over 255 addresses. When it goes over 255 > it goes to the beginning of the program. I use the PAGE command before and > after routines, but it must be larger than a page. > > I have to keep the code efficient because of the serial timing, I don't have > much room for additional code. > > What are my options? > > Is there an efficient way to make SSTATE a 16bit number and will that even > work? For example if SSTATE was at 355 would the program counter no where to > go? You can do something like this: MOVF SSTATE_HI,W ;Get the high byte of the destination MOVWF PCLATH ;(actually only bits 0-4 are used) MOVF SSTATE_LO,W ;Get the low byte MOVWF PCL ; However, if you know the destination bank AND it happens to be only one bit different than the current bank, then you could get by with BSF/BCF's. BSF PCLATH,0 ;Currently in bank 0, but we are about to ;branch into bank 1 MOVF SSTATE,W ;Get the low byte MOVWF PCL ; Needless to say, you'll have to be extremely careful how the states are grouped to avoid an inadvertent branch. Scott