please dont rip this site

Divide 14 bit integer using a fixed point divisor and result (7Q8 format)

;-----------------------------------------------------------------------------
; Input:
;  a1:a0 - 14 bit dividend   (a0 - lower byte)
;  b1:b0 - 15 bit divisor in 7Q8 format (b1 is integer, b0 is
;          fractional)
; Output:
;  c1:c0 - 15 bit quotient in 7Q8 format
;
; Size: 27 words
; Time: 3+3+3+15*(5+8+6)-2+3=295 instruction cycles
;
; March 13, 2001 by Nikolai Golovchenko
; March 14, 2001 optimized by Scott Dattalo
;-----------------------------------------------------------------------------
div_uint14_fxp7q8_fxp7q8
;left align the dividend
; (shift accumulator left 1 bit to get the first result bit weight
;  equal to 128)
        clc
        rl      a0
        rl      a1      ;carry is cleared here
;initialize registers
        clr     c0      ;clear result - it will be used
        clr     c1      ;to shift zeroes to dividend
        setb c0.1       ;15 iterations
div_loop
        rl      a0      ;shift out next bit of dividend
        rl      a1      ;to remainder
        mov     W, b0   ;load w with lower divisor byte
        snc             ;if remainder positive - subtract,
        jmp     div_add ;if negative - add
        ;subract
        sub     a0, W
        mov     W, b1
        sc
        movsz   W, ++b1
        sub     a1, W
        jmp     div_next
div_add
        ;add
        add     a0, W
        mov     W, b1
        snc
        movsz   W, ++b1
        add     a1, W
div_next
;here carry has a new result bit
        rl      c0      ;shift in next result bit
        rl      c1
        skpc
        jmp     div_loop
        retp


file: /Techref/scenix/lib/math/div10byfxp7q8.htm, 1KB, , updated: 2001/3/17 21:58, local time: 2024/12/25 05:30, owner: NG--944,
TOP NEW HELP FIND: 
3.141.21.106: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://massmind.org/techref/scenix/lib/math/div10byfxp7q8.htm"> Divide 10 bit integer using a fixed point divisor and result (7Q8 format)</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 massmind.org!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .