QUOTE: For a GOTO instruction, bits 8:0 of the PC are provided by the GOTO instruction word. The PC Latch (PCL) is mapped to PC<7:0>. Bit 5 of the STATUS register provides page information to bit 9 of the PC (Figure 4-8). For a CALL instruction, or any instruction where the PCL is the destination, bits 7:0 of the PC again are provided by the instruction word. However, PC<8> does not come from the instruction word, but is always cleared (Figure 4-8). The STATUS register page preselect bits are cleared upon a RESET, which means that page 0 is pre- selected. Therefore, upon a RESET, a GOTO instruction will automatically cause the program to jump to page 0 until the value of the page bits is altered. Because PC<8> is cleared in the CALL instruction, or any Modify PCL instruction, all subroutine calls or computed jumps are limited to the first 256 locations of any pro-gram memory page (512 words long). :------------------------------------ The last paragraph is interesting. Try making sure the sub-routine is in the PAGE1 but within the first 256 locations. Pete > -----Original Message----- > From: EXT Geoff Wootton [mailto:woottong@isdugp.bham.ac.uk] > Sent: Tuesday, July 11, 2000 2:03 PM > To: PICLIST@MITVMA.MIT.EDU > Subject: Re: [PIC]: 12C509 calls and gotos > > > Pete, > > Thanks for the reply. You're right, if I move the subroutine > closer it does work, however I'd rather be able to use the > full address range as documented. The 12C508 has 512 program > memory locations, so setting bit 5 of the status register > will (should) give full addressabilty. The datasheet is > ambiguous on addressing the 12C509. There are 1024 locations > and it says to set bits 5 and 6 of the status register but > later on says that bit 6 is not implemented. If I move the > subroutines closer to the calls then they will be embedded > in my main code which makes it less readable. Also I'd then > have to put gotos in to jump over the subroutines. I've thought > of using nested subroutines but the stack on the 12C509 only > has 2 levels. > > Regards > > Geoff. > > -- > http://www.piclist.com hint: The PICList is archived three different > ways. See http://www.piclist.com/#archives for details. > -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.