On 18 May 1994, Peter Knight
wrote:
> I take your point as a general idea, but come on - ADDWF f,d where d is
> *direction*!!! Whats wrong with ADD f,W / ADD W,f?
I agree with your comments about Microchip's syntax being suboptimal, but
I should point out that the ",d" doesn't specify the direction, it specifies
the destination. While this may seem like a minor point, consider the
SUBWF instruction:
SUBWF FOO,W ; W := FOO - W
SUBWF FOO,F ; F := FOO - W
While discussing subtract instructions, I should point out that the SUBLW
instruction subtracts the contents of W *FROM* the literal, which is not what
people generally expect.
At first this seemed brain-damaged but then I discovered that it is useful.
If you want to take the two's complement of W, for instance, you can use
SUBLW 0 ; W := 0 - W
If you want to subtract a literal from W, you can use the ADDLW
instruction with the two's complement of the literal:
ADDLW 0feh ; W := W - 2
Some assemblers will let you write this in a natural form:
ADDLW -2 ; W := W - 2
Cheers,
Eric