please dont rip this site

PIC Microcontoller Math Method

Divide 8 bits in W by the constant value 3

By: Andy Warren From: http://www.myke.com/basic.htm

an algorithm from Andy Warren for dividing a positive value by three, by knowing that divide by three can be represented by the series:

x/3 = x/2 - x/4 + x/8 - x/16 + x/32 - x/64...

The code to implement this is:

Div3:                     ;  Divide Contents of "w" by 3

  movwf  Dividend
  clrf   Quotient

Div3_Loop                 ;  Loop Until the Dividend == 0

  bcf    STATUS, C
  rrf    Dividend, f      ;  Dividend /2 (ie "x/2" in Series)
  movf   Dividend, w      ;   Is it Equal to Zero?
  btfsc  STATUS, Z
   goto  Div3_Done        ;  If it is, then Stop

  addwf  Quotient         ;  Add the Value to the Quotient

  rrf    Dividend, f      ;  Dividend /2 (ie "x/4" in Series)
  movf   Dividend, w
  btfsc  STATUS, Z
   goto  Div3_Done

  subwf  Quotient, f      ;  Quotient = Quotient-(Dividend / 4)

  goto   Div3_Loop

Div3_Done

  movf   Quotient, w      ;  Return the Quotient

  return


file: /Techref/microchip/math/div/8byconst3-aw.htm, 1KB, , updated: 2011/1/17 22:59, local time: 2024/11/15 03:34,
TOP NEW HELP FIND: 
18.118.163.255: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.ecomorder.com/techref/microchip/math/div/8byconst3-aw.htm"> PIC Microcontoller Math Method </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 ecomorder.com!

 

Welcome to massmind.ecomorder.com!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .