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: 2+3+3+15*(2+3+7+5)-1+2=264 instruction cycles
; March 13, 2001 by Nikolai Golovchenko
; March 14, 2001 optimized by Scott Dattalo

;left align the dividend
; (shift accumulator left 1 bit to get the first result bit weight
;  equal to 128)
        rlf     a0, f              
        rlf     a1, f              ;carry is cleared here
;initialize registers
        clrf c0                    ;clear result - it will be used
        clrf c1                    ;to shift zeroes to dividend
        bsf c0, 1                  ;15 iterations
        rlf a0, f                  ;and shift out next bit of dividend
        rlf a1, f                  ;to remainder

        movf b0, w                 ;load w with lower divisor byte
        skpnc                      ;if remainder positive - subtract,
         goto div_add              ;if negative - add
        subwf a0, f
        movf b1, w
         incfsz b1, w
          subwf a1, f
        goto div_next
        addwf a0, f
        movf b1, w
         incfsz b1, w
          addwf a1, f
;here carry has a new result bit
        rlf c0, f                  ;shift in next result bit
        rlf c1, f
         goto div_loop

file: /Techref/microchip/math/div10byfxp7q8.htm, 2KB, , updated: 2001/3/17 23:00, local time: 2023/3/30 23:20, owner: NG--944,

 ©2023 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=""> 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?

  PICList 2023 contributors:
o List host: MIT, Site host, Top posters @none found
- Page Editors: James Newton, David Cary, and YOU!
* Roman Black of Black Robotics donates from sales of Linistep stepper controller kits.
* Ashley Roll of Digital Nemesis donates from sales of RCL-1 RS232 to TTL converters.
* Monthly Subscribers: Gregg Rew. on-going support is MOST appreciated!
* Contributors: Richard Seriani, Sr.

Welcome to!