please dont rip this site

SX Microcontroller Math Method

Fast 8 Bit Square Root

by Nikolai Golovchenko

;***********************************************
;
; 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: 2024/3/28 14:26, owner: NG--944,
TOP NEW HELP FIND: 
44.222.146.114: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?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://techref.massmind.org/techref/scenix/lib/math/sqrt/sqrt8fast_sx.htm"> SX Microcontroller Math Method Fast 8 Bit Square Root</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

 

Welcome to massmind.org!

 

Welcome to techref.massmind.org!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .