; ACC = ACC * 0.152588
; Temp = TEMP
; ACC size = 16 bits
; Error = 0.1 %
; Bytes order = big endian
; Round = no
; ALGORITHM:
; Clear accumulator
; Add input / 8 to accumulator
; Add input / 32 to accumulator
; Substract input / 256 from accumulator
; Add input / 4096 to accumulator
; Move accumulator to result
;
; Approximated constant: 0.152588, Error: 4.096e-007 %
; Input: ACC0 .. ACC1, 16 bits
; Output: ACC0 .. ACC1, 14 bits
; Code size: 54 instructions
cblock
ACC0
ACC1
TEMP0
TEMP1
endc
;copy accumulator to temporary
movf ACC0, w
movwf TEMP0
movf ACC1, w
movwf TEMP1
;shift accumulator right 4 times
swapf ACC1, w
andlw 0x0F
movwf ACC1
swapf ACC0, w
movwf ACC0
andlw 0xF0
iorwf ACC1, f
xorwf ACC0, f
;substract temporary from accumulator
movf TEMP1, w
subwf ACC1, f
movf TEMP0, w
skpc
incfsz TEMP0, w
subwf ACC0, f
;shift accumulator right 3 times
rrf ACC0, f
movlw 0x80
xorwf ACC0, f ;invert bit shifted from carry
rrf ACC1, f
rlf ACC0, w
rrf ACC0, f
rrf ACC1, f
rlf ACC0, w
rrf ACC0, f
rrf ACC1, f
;add temporary to accumulator
movf TEMP1, w
addwf ACC1, f
movf TEMP0, w
skpnc
incfsz TEMP0, w
addwf ACC0, f
;shift accumulator right 2 times
clrc
rrf ACC0, f
rrf ACC1, f
clrc
rrf ACC0, f
rrf ACC1, f
;add temporary to accumulator
movf TEMP1, w
addwf ACC1, f
movf TEMP0, w
skpnc
incfsz TEMP0, w
addwf ACC0, f
;shift accumulator right 3 times
rrf ACC0, f
rrf ACC1, f
clrc
rrf ACC0, f
rrf ACC1, f
clrc
rrf ACC0, f
rrf ACC1, f
; Generated by www.piclist.com/cgi-bin/constdivmul.exe (1-May-2002 version)
; Wed Apr 20 13:37:29 2011 GMT