please dont rip this site

PIC Microcontoller Math Method

32 bits by 16 by Peter Hemsley

divide movlw 32      ; 32-bit divide by 16-bit
       movwf bitcnt
       clrf remdrH   ; Clear remainder
       clrf remdrL

dvloop clrc          ; Set quotient bit to 0
                     ; Shift left dividend and quotient
       rlf divid0    ; lsb
       rlf divid1
       rlf divid2
       rlf divid3    ; lsb into carry
       rlf remdrL    ; and then into partial remainder
       rlf remdrH

       skpnc         ; Check for overflow
       goto subd
       movfw divisH  ; Compare partial remainder and divisor
       subwf remdrH,w
       skpz 
       goto testgt   ; Not equal so test if remdrH is greater
       movfw divisL  ; High bytes are equal, compare low bytes
       subwf remdrL,w
testgt skpc          ; Carry set if remdr >= divis
       goto remrlt

subd   movfw divisL  ; Subtract divisor from partial remainder
       subwf remdrL
       skpc          ; Test for borrow

       decf remdrH   ; Subtract borrow
       movfw divisH
       subwf remdrH
       bsf divid0,0  ; Set quotient bit to 1
                     ; Quotient replaces dividend which is lost
remrlt decfsz bitcnt
       goto dvloop
       return

Comments:

Questions:


file: /Techref/microchip/math/div/32by16ph.htm, 2KB, , updated: 2020/2/12 20:49, local time: 2024/3/29 06:07, owner: JMN-EFP-786,
TOP NEW HELP FIND: 
3.88.185.100: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://piclist.com/techref/microchip/math/div/32by16ph.htm"> 32 bits by 16 by Peter Hemsley</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 2024 contributors:
o List host: MIT, Site host massmind.org, 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 piclist.com!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .