source= http://www.piclist.com/postbot.asp?id=piclist\2002\02\01\200323a ; ACC = ACC * 0.00392157 ; Temp = TEMP ; ACC size = 16 bits ; Error = 0.1 % ; Bytes order = little endian ; Round = no ; ALGORITHM: ; Clear accumulator ; Add input / 256 to accumulator ; Add input / 65536 to accumulator ; Move accumulator to result ; ; Approximated constant: 0.00392151, Error: 0.00152588 % ; Input: ACC0 .. ACC1, 16 bits ; Output: ACC0 .. ACC1, 9 bits ; Code size: 15 instructions cblock ACC0 ACC1 TEMP0 TEMP1 endc ;copy accumulator to temporary movf ACC1, w movwf TEMP1 movf ACC0, w movwf TEMP0 ;shift accumulator right 8 times movf ACC1, w movwf ACC0 ;add temporary to accumulator clrf ACC1 movf TEMP0, w addwf ACC0, f movf TEMP1, w skpnc incfsz TEMP1, w addwf ACC1, f ;shift accumulator right 8 times movf ACC1, w movwf ACC0 ; Generated by www.piclist.com/cgi-bin/constdivmul.exe (November 17, 2000 version) ; Sun Feb 03 23:18:44 2002 GMT --- James Newton: PICList.com webmaster, former Admin #3 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 hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.