In SX Microcontrollers, SX/B Compiler and SX-Key Tool, natpie wrote: It sounds to me like you don't want XOR. If you want to keep bits 0 to 3 as they are and clear 4 to seven you would AND 00001111. Xor (exclusive or) sets a bit as 1 ONLY if ONE and ONLY ONE of the bits is 1. 1 XOR 1 = 0 0 XOR 0 = 0 1 XOR 0 = 1 0 XOR 1 = 1 AND on the other hand requires both bits to be 1. So... 1 AND 1 = 1 0 AND 0 = 0 1 AND 0 = 0 0 AND 1 = 0 Also in your code you did an xor $12, #%00001111 ;"1" to Copy the Bit, "0" clears the Bit mov rc, W This will ALWAYS put %00001111 in rc. The way you used XOR is not supporterd by the chip so the assymbler brakes this into two instructions. MOV W, #%0000111 XOR $12, W At this point $12 contains the new XORed value, and W contains %00001111. ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=367991#m368008 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2009 (http://www.dotNetBB.com)