> 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? Multiply by 1/10 ; ACC = ACC * 0.1 ; Temp = TEMP ; ACC size = 8 bits ; Error = 0.5 % ; Bytes order = little endian ; Round = no ; ALGORITHM: ; Clear accumulator ; Add input / 16 to accumulator ; Add input / 32 to accumulator ; Add input / 256 to accumulator ; Add input / 512 to accumulator ; Move accumulator to result ; ; Approximated constant: 0.0996094, Error: 0.390625 % ; Input: ACC0, 8 bits ; Output: ACC0, 5 bits ; Code size: 17 instructions cblock ACC0 endc ;copy accumulator to temporary movf ACC0, w ;shift accumulator right 1 times clrc rrf ACC0, f ;add temporary to accumulator addwf ACC0, f ;shift accumulator right 3 times rrf ACC0, f clrc rrf ACC0, f clrc rrf ACC0, f ;add temporary to accumulator addwf ACC0, f ;shift accumulator right 1 times rrf ACC0, f ;add temporary to accumulator addwf ACC0, f ;shift accumulator right 4 times swapf ACC0, w andlw 0x0F movwf ACC0 skpnc bsf ACC0, 4 ; Generated by www.piclist.com/cgi-bin/constdivmul.exe (1-May-2002 version) ; Thu Feb 23 18:29:05 2006 GMT See also: http://www.piclist.com/techref/microchip/math/div/index.htm --- James Newton: PICList webmaster/Admin mailto:jamesnewton@piclist.com 1-619-652-0593 phone http://www.piclist.com/member/JMN-EFP-786 PIC/PICList FAQ: http://www.piclist.com -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist