Hi Scott. 16 perhaps ? :) Scott Dattalo wrote: > > One in particular takes 18 cycles. > > SWAPF bin, W ;w = A0*16+A1 > ADDWF bin, W ;w = A0+A1 > ANDLW 00001111b ;w = A0+A1 % 16 > SKPNDC ;if A0+A1 > 16 > ADDLW 0x16 ; w += 16 >> SKPNDC ;if w % 16 > 10 >> ADDLW 0x06 ; w += 6 With input value in range 00..63h(99.) I don't see the reason why second skpndc check is required ? When dc flag is generated in first instance maximum resulting value is 0x5 + 0xF = 0x14 I think these two lines can be safely omitted. WBR Dmitry. PS. And final steps 0x40 -> 0x60 and 0x20 -> 0x30 are begging for some optimization as well. :) > ADDLW 0x06 ;w += 6 > SKPDC ;if w < 10 > ADDLW -0x06 ; w -= 6 > > BTFSC bin,4 > ADDLW 0x16 - 1 + 0x6 > SKPDC > ADDLW -0x06 > > BTFSC bin, 5 > ADDLW 0x30 > > BTFSC bin, 6 > ADDLW 0x60 > > ; result is in W > > This was adapted from: > http://www.piclist.com/techref/microchip/math/radix/b2bhp-8b3d.htm > And the algorithm is described: > http://www.piclist.com/techref/method/math/radixs.htm > > Scott > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist