Beruflich Dokumente
Kultur Dokumente
approximation to find the square root, the binary restoring method I'm fairly sure
would be quicker. This is the only 16-bit sqrt routine I have specifically for the
17cxx PICs, I've only included it as the original poster requested a 16-bit
routine. If you really want speed speed speed, I'd rewrite the 32-bit routine to be
16-bit.
Standard disclaimer applies
;==========================================================================
; SQRT16
;
; Calculates the square root of a sixteen bit number by successive
; approximation.
;
;
; Input in ACCaHI:ACCaLO
;
; Output in ACCbHI
;
; Also uses ACCbLO and ACCcHI.
;
;--------------------------------------------------------------------------
SQRT16:
movlw 0x80 ;
movpf WREG,ACCbLO ; set up walking tester bit.
clrf ACCbHI,w ;
movlw 0x08 ;
movpf WREG,ACCcHI ;
decfsz ACCcHI,f ;
goto tstest ;
return
Divide 16 bits by the constant value 10 by Alec_t
from: http://www.chatzones.co.uk/discus/messages/7/DivideByTen-11542.txt