Yes Michael I mean 256 in case of CALL (one x is mistyped) and I made a mistake in case of GOTO cmd (I have to look into datasheet instead of trying to remember it). And probably subroutine have to start no later than 255 word on each program page(first address is 0). WBR Dmitry. Michael J. Ghormley wrote: > > Dmitry Kiryashov wrote: > > > > Look into 509 > > datasheet and you will find that CALL or GOTO commands may only load > > 0xxxxxxx into PCL or another words only first half of every program > > page is accessable through that commands. This also related to ADDWF > > PCL,F command. > > I think that you might have mis-read this Dmitry. From the datasheet: > > 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). > > Thus, my reading of this is that you can GOTO anywhere within the 512 byte > page. > > Again, from the datasheet: > > 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). > > Thus, you are correct about only being able to CALL within the first half > of a page, but you are missing an 'x' in 0xxxxxxx which makes it look like > the call is only addressing the first seven bits. The first half of a page > is 256 bytes -- not 128. It seems that Andre must have a sub-routine > between 256 and 382, yes? > > Moving the sub-routine's label up in the code will most likely fix the > problem. > > Of course, I may be wrong about this and would very much like to know if I > have mis-read the datasheet, or if the datasheet is wrong. > > Michael > > ************************************************************************* > When the way of the Tao is forgotten, kindness and ethics must be taught. > Men must learn to pretend to be wise and good. -- Lao Tzu > *************************************************************************