On Wed, Feb 22, 2006 at 02:50:53PM +0100, J?hn Bal?zs wrote: > Hi, > > I want a 8 bit number divide by 10 (ten). > I need the quotient and the remain. > > Which is the fastest ASM code for pic 16f877? Simple. Table lookup. Costs 512 instructions for the RETLWs and 2 or so instructions for the setup for the jump. Something along the lines of: org 0x01ff ; Start on instruction short of 256 instruction ; boundary. How can this be done in a ; relocatable fashion? div10q: addwf PCL,F retlw 0 ; 0/10 = 0 retlw 0 ; 1/10 = 0 ; ... up to 9 then retlw 1 ; 10/10 = 1 retlw 1 ; 11/11 = 1 and so forth. BAJ -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist