Hi, Peter L. Peres wrote: >> better > >decf mid, F >decf mid, F >decfsz low, F > incf mid, F >incfsz mid, F > decf high, F > >6 T cycles, 6 words run time (constant), and no changes in W ;). I think >it's optimal. > >Peter I like the pair of "decf" followed by an "incfsz", however this takes the same time/space as a "movf X,f / skpz" combination. This has several problem where it returns incorrect values. One problem is the decfsz low,F will skip when low transfer from 1 to 0 not from 0 to FF. If access is well controlled this can be "fixed" by loading values with 1 greater than target and reading the values with a "decf X,w" instead of a "movf X,w". However this makes the value only useful as a down counter. Another problem is handling the borrow out of the mid byte. To be sucessful you must decrement high only if (low WAS 0 or BECOMES FF) AND (mid WAS 0 or BECOMES FF). Any implementation which only tests mid to determine if high should be decremented will fail when mid is FF and low did not underflow. There are some good ideas in this approach, I fiddled with it a bit but did not come up with a low cost and correct version. Chip Weller