piclist 2003\03\02\125222a >
Thread: Some Basic Questions
picon face BY : Jonny Taylor email (remove spam text)

{Quote hidden}

If you look in the header files then you will see that W is a constant
defined to be 0, and is intended for use as the second argument to an
instruction which can have a destination of W (W=0) or the source register
(F=1). You are therefore writing the following instruction:
   incf 0,0

Looking in the datasheet at the definition of the incf instruction, you will
see that this means "take the value in register 0 in the current bank,
increment it and store the result in the working register (W)".

W is not a register that is addressable like other registers (if I remember
rightly for the processor you are using). On some processors there is a
register (normally named WREG) which is the working register.

To increment the working register, use ADDLW 1.

The fact that the first incf instruction that you tried did appear to
increment the working register was a coincidence - register 0 was read as 0.
It was still read as 0 for your second incf instruction, so W was still set
to 1 after the second incf.

MPASM does not give error messages because the instruction you wrote was
perfectly valid. It just wasn't doing what you thought it was doing.


http://www.piclist.com hint: To leave the PICList
<E18pXd2-0005dH-00@smtp1.herald.ox.ac.uk> 7bit

See also: www.piclist.com/techref/microchip/languages.htm?key=basic
Reply You must be a member of the piclist mailing list (not only a www.piclist.com member) to post to the piclist. This form requires JavaScript and a browser/email client that can handle form mailto: posts.
Subject (change) Some Basic Questions

month overview.

new search...