please dont rip this site

SX Microcontroller Bit Math Method


Testing bits in W

Dmitry Kiryashov says:

You can't apply sb/snb operations to [the W register ]. You need to put W value to some temp location first and finally check temp with sb / snb commands. [ed: unless you have optionx_carryx (or optionx on the old parts) in your device directive and have the RTW bit 7 of the option register cleared, then register 1 becomes the W register rather than the RTCC. The RTCC continues to work, but can't be read untill that bit is set. This is specific to the SX line of processors]

HINTS:

  1. 	and	W, #$80	; will test bit .7 in W, other bits are cleared ;-)
    	and	W, #$40	; test bit .6
    ;...
    

    result of operation in Z flag (=0 means bit=1 otherwise bit=0 result to Z=1)

    and W, #$xx is destructive command. You cannot restore W if you didn't save it before.

  2. You can also apply XORLW value command to check identity W to some value. It is useful command (sometimes) 'cause you can do comparison for alot of values and restore W after that to initial value.
    	xor	W, #A_CONST
    	snb	Z
    	jmp	A_CONST_MATCH
    
    	xor	W, #B_CONST^A_CONST	;compare with B_CONST
    	snb	Z
    	jmp	B_CONST_MATCH
    
    	xor	W, #C_CONST^B_CONST	;compare with C_CONST
    ;....
    
    	xor	W, #LAST_CONST	;last used const value -> restore initial W
    ;.....
    

See also:


file: /Techref/scenix/lib/math/bit/testbitsw_sx.htm, 1KB, , updated: 2004/6/10 13:40, local time: 2012/2/10 14:19,
TOP NEW HELP FIND: 
38.107.179.230:LOG IN

 ©2012 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://www.piclist.com/techref/scenix/lib/math/bit/testbitsw_sx.htm"> PIC Microcontroller Bit Math Method Testing bits in W</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 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?

 
Stepper motors CAN be smooth!
And stepper controllers can be strong and cheap. Roman Black's Linistep stepper controller kits:
o 18th microstep
o Linear smoothing
  o Open source
o Full kit $25!
 

Robotics nuts!

Check out http://users.frii.com/dlc/robotics/projects/botproj.htm from Dennis Clark. This guy ROCKS! He has made (and sells but also releases code, docs, etc...) for a number of cool little robotic modules including whiskers, IR proximity detect and remote control, Sonar proximity detect, PWM, Servo, compass. Most of these use the little PIC 12C508 controller which costs basically nothing and is soooo tiny.
The 4 servos, 2400 baud serial servo controller is a wonder of magic and he sells the programmed chip for $8. Wow!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .