please dont rip this site

PIC Microcontoller Basic Math Inc/Dec Methods

Also:

From http://www.myke.com/basic.htm: Incrementing/Decrementing "w"

Here are a couple of snippets that will allow you to increment and decrement the "w" register without affecting any file registers if you don't have "addlw"/"sublw" instructions (ie in the case of the low-end processor).

"Reg" can be any register that does not change during the execution of the three instructions. For the low-end parts, any file register can be used because there is no danger of them being updated by an interrupt handler.

To Increment:

 xorlw 0x0FF              ;  Get 1s Complement of Number
  addwf Reg, w             ;  w = Reg + (w^0x0FF)
  subwf Reg, w             ;  w = Reg + ((Reg + (w^0x0FF))^0x0FF) + 1
                           ;  w = w + 1

To decrement, the instructions are re-arranged:

 subwf Reg, w             ;  w = Reg + (2^0x0FF) + 1
  xorlw 0x0FF              ;  Get 1s Complement of Result
  addwf Reg, w             ;  w = w - 1

Archive:

Questions:


file: /Techref/microchip/math/incdec/index.htm, 2KB, , updated: 2010/3/26 14:54, local time: 2024/11/24 10:38,
TOP NEW HELP FIND: 
18.191.165.192: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://sxlist.com/TECHREF/microchip/math/incdec/index.htm"> PIC Microcontoller Basic Math Inc/Dec Methods</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 sxlist.com!


Site supported by
sales, advertizing,
& kind contributors
just like you!

Please don't rip/copy
(here's why

Copies of the site on CD
are available at minimal cost.
 

Welcome to sxlist.com!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .