You need to re-evaluate your programming techniques a little for PIC assembly. W is not a file register, but the working register. incf = increment FILE register, etc. The reason the behaviour you are witnessing with incf W, W is because it incremented a FILE register pointed to by W, and placed the result in W. The register pointed to by W was 0x00, because you cleared W. File register at 0x00 was zero to start with (no guarantees on that though !). That is why each incf W,W came back with the same result ! Get used to not performing these operations on W. W is really just a go between for file registers, and for setting flags in STATUS, such as Zero, Carry, etc. (note that many file register operations set STATUS flags anyway, so even this usage is really unnecessary except for code optimization sometimes) - all the juicy things happen with file registers. It's a bit of a PIC thing, just get used to moving W into, say, a temporary register before performing bit shifting, increments, or decrements. Really, you should only be doing this on file registers to start with (i.e. re-evaluation of technique here ;) ). W is effected differently for many of these operations. Any static results you wish to keep should be in file registers to start with. The reasons for this are many, for example, optimisation, and to keep each instruction to a single cycle. 1) Because the assembler allows W to point to a file register for these operations. I don't personally like this sort of syntax though, and think it SHOULD report these as errors. To recode 2) properly, you would write something like: movwf Temp incf Temp, F incf Temp, F incf Temp, W ; (last incf places result in W) But really, you should be using a file register in the first place, not W - and the result becomes even simpler, e.g. clrf Temp incf Temp, F incf Temp, F incf Temp, F or optimized ... movlw 0x03 addwf Temp Hope all this helps Rgs Ian -----Original Message----- From: pic microcontroller discussion list [mailto:PICLIST@MITVMA.MIT.EDU]On Behalf Of Biswanath Dutta Sent: Monday, 3 March 2003 3:38 am To: PICLIST@MITVMA.MIT.EDU Subject: [PIC]: Some Basic Questions I'm essentially a beginner using PIC16F877 and trying to develop some code. I have discovered the following and would someone please clear the confusion -- 1) incf, rlf, rrf type instructions do not seem to work properly on W. Is it so ? Why ? Microchip Datasheet doesn't mention anything regarding this. 2) Why doesn't MPASM give error messages when the above instructions are used on W 2) I entered the following code assembled and ran MPSIM clrw incf W,W incf W,W incf W,W While single stepping through , W is incremented on the first incf and not on the subsequent two incf . WHY Thanks in advance -- Biswanath Dutta -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu