;***********************************************
;
; 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
;***********************************************
See also:
| file: /Techref/scenix/lib/math/sqrt/sqrt8fast_sx.htm, 2KB, , updated: 2004/6/10 13:40, local time: 2012/2/10 13:28,
owner: NG--944,
38.107.179.231:LOG IN |
| ©2012 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? <A HREF="http://www.piclist.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? |
|
PIC 16 series Microcontroller Instruction Set Reference. And his Hobby Electronics web site at http://hobby_elec.piclist.com. |
|
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) |
.