You can not swap the W-reg in tha (the first) way. The second example is OK. W-reg is not accessable as an SFR. And of course it's in the manuals... :-) Note, do *not* use "0" and "1" as the destination bit in commands, use "W" and "F" instead. Much clearer. That is : > MOVLW 0x4F > MOVWF TEMPREG > SWAPF TEMPREG, W Than it also clear why : > MOVLW 0x4F > SWAPF W, W didn't work, right ? SFR with adress "0" is *not* the W-reg... Jan-Erik. Anand Gadiyar skrev: > 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: > > MOVLW 0x4F > MOVWF TEMPREG > SWAPF TEMPREG,0 > > This gives me 0xF4 in W register. > > I couldn't find this in the manuals. Any comments? Is the PIC > supposed to behave this way? Then, why isn't it there in the > Instruction Reference. > > Please forgive me if I'm missing something. Like I said before, I'm a newbie. > > Thanks in advance, > Anand > > _______________________ > Anand Gadiyar, > CEDT, > Indian Institute of Science, > Bangalore - 560 012 > India > _______________________ -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist