In SX Microcontrollers, SX/B Compiler and SX-Key Tool, yllawwally wrote: I have port rc set to output to leds, and port ra is hooked up to switches. I expect the code to wait until rb.1 is activated. Then I want the information from rb put into location 12, and I want bits 7 to 4 cleared. Then I want this outputed to rc. If I remove the xor line it works except that bits 7 to 4 need to be cleared. However when I have the xor statement, bits 7 to 4 are cleared, and 3 to 0 are set. I was hoping someone could tell me where I'm going wrong. The final code I'm trying to write, will take bits 0 to 3 and then activate an external chip select on ra.0 and then move bits rb.5 to location $12.5, rb8 to location $12.6. [code] mov W,#$1F ;Allow Direction configuration mov M,W mov !rb,#%11111111 ;Set port B bits 0-7 to input mov !ra,#%00000000 ;Set port A bits 0-7 output bit 0 is select mov !rc,#%00000000 ;Set port C bits 0-7 output bwait jnb rb.1,bp0 jmp bwait ;keep repeating until rb.1 activated bp0 clrb ra.0 ;turn select off ;-------------------bit copy mov W, rb mov $12, W xor $12, #%00001111 ;"1" to Copy the Bit, "0" clears the Bit mov rc, W ;-------------------bit copy jmp bp0 [/code] ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=367991 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)