Hi Stewart, I've included this on the PICList because there are probably a few people who would be interested in what is going on here. >I have a current interest in 16 bit up/down counting. Referring to page 298 >of your book, you handle separately the required increment/decrement >functions and the zero sensing functions. Is there a reason why you have not >used incfsz and decfsz, which combine these functions, and would seem to >offer a more direct and symmetrical way to deal with this issue? I have not included "incfsz" and "decfsz" instructions in the 16 bit increment/decrement because they won't work in these applications. the instructions: incfsz Count incf Count+1 appears to do a 16 bit increment, but actually increments "Count+1" every time _except_ when the result of incrementing "Count" is equal to zero. Now, on page 243, I show how this is used as a short timer: Loop incfsz Count incf Count btfsc PORTA,bit ; Wait for the Bit goto Loop movf Counthi,w subwf Count,w movwf Counthi To properly increment a 16 bit number, you have to use the "incf" and "btfsc" as I outlined in the book. incf Count btfsc STATUS, Z incf Count+1 Decrementing a 16 bit value is a bit more of a problem, because "decfsz" only skips when the result is equal to zero. If you were to make the code: decfsz Count decf Count+1 Like, the two instruction sixteen bit increment, you would end up decrementing the high value everytime except when the result of decrementing "Count" is equal to zero. Decrement is further complicated by the fact that decrementing to zero doesn't mean anything (unlike incrementing to zero, which means you actually have reached 0x0100). So, to get the sixteen bit decrement to work properly, you have to _subtract_ by one, to get to 0x0FF, which is where you want to decrement the high byte. This is why I use the code: movlw 1 subwf Count btfss STATUS, C ; If Carry Not Set, Then Gone from 0 to 0x0FF decf Count+1 Increment and decrement are shown in more detail on pages 77-78. Good luck, myke >Stewart Krakauer > > > > > "If people don't know what you're doing, they don't know what you're doing wrong." - Sir Humphrey Appleby K.C.B