;***********************************************
;
; 8 bit Fast Square root
;
; Input: x (not changed)
; Output: y
; Temporary: Temp
;
; Instructions: 29
; Execution time (includng return):
; 31 cycles
;
; August 9, 2000 by Nikolai Golovchenko
;
;***********************************************
sqrt8fast
mov W, x ;1
mov Temp, W
clr y
;find bit 3 of result
mov W, #$40 ;4
sub Temp, W
rl y
sb y.0
add Temp, W ;restore Temp
;find bit 2 of result
or W, #$10 ;9
sb y.0
xor W, #$40
sub Temp, W
rl y
sb y.0
add Temp, W ;restore Temp
;find bit 1 of result
mov W, <>y ;y = 16 * result<3:2>
or W, #$04 ;set bit 1
sub Temp, W ;Temp - (4 * (4 * result<3:2> + 1))
rl y ;store result
sb y.0 ;20
add Temp, W ;restore Temp
;find bit 0 of result
xor W, #$0E ;set bit 0 and compensate for set bit 0 in previous substaction
sb y.0 ;24
xor W, #$08
rl Temp ;shift left the remainder (carry ignored)
sub Temp, W ;Temp - (4 * (4 * result<3:1> + 1))
rl y ;if borrow clear bit 0 and set otherwise
ret ;31
;***********************************************
| file: /Techref/scenix/lib/math/sqrt/sqrt8fast_sx.htm, 2KB, , updated: 2004/6/10 14:40, local time: 2010/9/3 02:49,
owner: NG--944,
38.107.191.80:LOG IN
|
| ©2010 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? Please DO link to this page! Digg it! <A HREF="http://www.sxlist.com/techref/scenix/lib/math/sqrt/sqrt8fast_sx.htm"> SX Microcontroller Math Method Fast 8 Bit Square Root</A> |
| Did you find what you needed? |
|
Enter the PICList design contest to win a free PCB from olimex.com! sales, advertizing, & kind contributors just like you! Please don't rip/copy (here's why Copies of the site on CD are available at minimal cost. |
|
Ubicom SX18 thru SX52, PIC 16c5X compatibile, 50 to 75 MIPS microcontrollers! Now US customers can buy the Excellent SXDev from SXList.com for $150 + $15 import fee + s&h (~ $180 total+tax in CA) |
.