Some Basic Questions
Jonny Taylor email (remove spam text)
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:
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
See also: www.piclist.com/techref/microchip/languages.htm?key=basic
You must be a member of the
piclist mailing list
(not only a www.piclist.com member) to post to the