On Tue, 4 Jun 2002, Scott Dattalo wrote: >On Mon, 3 Jun 2002, Dmitriy A. Kiryashov wrote: > >> Hi guys. Here is tiny challendge to warm up. ;) >> >> We have X variable. What is shortest possible >> code to obtain 2X + 1 result back into X cell ? >> > >How about: > >sdcc -S -mpic14 c.c > >... > >;; Unrolled 8 X 8 multiplication >;#CSRC c.c 71 >; achar0 = achar0*2 + 1; > MOVF _achar0,W ;key=000,flow seq=001 > MOVWF r0x20 ;key=001,flow seq=001 > ADDWF r0x20,F ;key=002,flow seq=001 > CLRF r0x21 ;key=003,flow seq=001 > RLF r0x21,F ;key=004,flow seq=001 > INCF r0x20,W ;key=005,flow seq=001 > MOVWF _achar0 ;key=006,flow seq=001 > >I think I hate C compilers. :) That's a 8x8 multiplication by a *constant*, no ? Did you not draw upon Dmitry's excellent multiplier/divider code to generate that sort of code ? Peter -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu