>-----Original Message----- >From: piclist-bounces@mit.edu [mailto:piclist-bounces@mit.edu] >On Behalf Of Anand Gadiyar >Sent: 26 February 2007 12:38 >To: PICList >Subject: [PIC] : SWAPF Instruction's strange behavior > > >Hi all, > > I've been playing around with a PIC 16F877A now. I'm a >newbie. I seem to have found strange behavior while using the >SWAPF instruction. > >Here's the code I tried in MPLAB SIM. > >MOVLW 0x4F >SWAPF W,0 > >This code seems to be zeroing out the W register instead of >exchanging the nibbles like it's meant to. I had to work >around it by writing the word to a temporary register and >swapping it like this: The clue is the 'F' in the mnemonic name; SWAPF means swap the nibbles in a FILE register. You can not specifify W as a register to work on, only as a destination for the result. Regards Mike ======================================================================= This e-mail is intended for the person it is addressed to only. The information contained in it may be confidential and/or protected by law. If you are not the intended recipient of this message, you must not make any use of this information, or copy or show it to any person. Please contact us immediately to tell us that you have received this e-mail, and return the original to us. Any use, forwarding, printing or copying of this message is strictly prohibited. No part of this message can be considered a request for goods or services. ======================================================================= -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist