;*********************************************** ; ; 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 13:40, local time: 2024/12/22 05:30,
owner: NG--944,
13.58.110.182:LOG IN
|
©2024 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://massmind.org/Techref/scenix/lib/math/sqrt/sqrt8fast_sx.htm"> SX Microcontroller Math Method Fast 8 Bit Square Root</A> |
Did you find what you needed? |
Welcome to massmind.org! |
Welcome to massmind.org! |
.