Hi Scott. You are absolutely right. I didn't say actually 2 clocks did I ? ;) I was thinking about extending previous case by one more command. 2x-1 = 2(x-1)+1 which Ruben Jvnsson has perfectly found. decf X,F ;0 -> 0xFF setc rlf X,F ;0xFF<1 -> Cy=1,0xFF WBR Dmitry. Scott Dattalo wrote: > > On Thu, 6 Jun 2002, Dmitriy A. Kiryashov wrote: > > > Hi Scott. > > > > > decf x,w ;w = x-1 > > > addwf x,f ;x = x+x-1 = 2*x-1 > > > > What about case when x == 0 ? > > > > 0 + 0xFF = 0xFF and Cy=0 (should be Cy==1(borrow) ) > > I'm not going to play anymore if you change the rules :) (In other words, > I can't see a 2-instruction solution that handles the carry as you request > here.) > > Scott -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics