On Mon, 7 Sep 1998 15:41:17 -0400 Shahid Sheikh writes: >I'm having a little problem understanding how the PC on a 12C508 >works. I have a scenario where I want to skip a number of instructions in the >code >and the number is specified in the variable X. So I have code that >looks >something like > > movf X ;X is the number of instructions to skip > addlw PCL, f ;Add X to PC. > In my above example, if the value of X is zero, will that cause the program to >freeze? The value read from PCL by the addwf (not addlw) instruction will be the address of the next instruction. If you add zero, the program will continue with the next instruction, though with an extra cycle of delay. If you add FF (-1), the addwf PCL instruction will execute in an infinite loop. If you add one, the next instruction will be skipped, adding two skips over 2 instructions, and so on. Of course the entire part of the program involving the skipping must be in the first 256 instruction subpage of the program space. It is not possible to go outside the first 256 instructions with a write to PCL on a 12C508. If the result of the add overflows, the program will continue in the first part of the program space. >Or is that considered a situation in which the "instruction does not >change the PC." Every instruction that writes to PCL is treated as a goto, requiring an extra cycle. It doesn't matter what value is written. _____________________________________________________________________ You don't need to buy Internet access to use free Internet e-mail. Get completely free e-mail from Juno at http://www.juno.com Or call Juno at (800) 654-JUNO [654-5866]