On Sat, Mar 27, 2010 at 08:46:35PM -0400, Bo Dirigo wrote: > While studying various PIC instructions' formats, I noticed a number of > instructions that had a 'd' (destination) in the Mnemonic; e.g., MOVF > f,d; ADDWF f,d; INCF f,d, et al. > > If d=0, the results are stored in the W register - ADDWF FSR, 0 > If d=1, the results are stored in the f register - ADDWF FSR, 1 Correct. Every instruction that has W and a file register as an operand may specify either as the target of the result. > > My question is "Do you need to specify the "0" value if one knows they > want the resultant value to be stored in the W register?" No. There is a default. But honestly I can never remember which one it is. > Obviously, if > one wants the result to be stored in the f register, they must specify > the "1" value. I'm probably all wet here, but was thinking perhaps the > assembler would automatically default to the "0" value if nothing > specified. Again, I can never remember. So I always specify the target. Fortunately both MPASM and gpasm will generate a warning if you use the default. > Before you shoot me, I am in agreement it would be better to > specify either a "0" or "1" depending on what it is one wants done. I'm > just curious. Finally in the include files the names W and F are defined to set that destination. So no one ever uses the 0 or 1 value to specify the target. This is done precisely because the numbers convey no semantic information. An instruction like: addwf PCL,F In much clearer than: addwf PCL,1 I cannot remember the last time I've seen the latter notation in a piece of code. And no matter what the default is: addwf PCL Is just a train wreck waiting to happen. But just for the record this piece of code: LIST P=16F88 #include "p16f88.inc" ORG 0 addwf PCL,W addwf PCL,F addwf PCL END Generates the following listing: 00001 00002 00003 00004 LIST P=16F88 00005 #include "p16f88.inc" 00001 LIST 00002 ; P16F88.INC Standard Header File, Version 1.00 Microchip Technology, Inc. 00401 LIST 00006 0000 00007 ORG 0 0000 0702 00008 addwf PCL,W 0001 0782 00009 addwf PCL,F Message [305] : Using default destination of 1 (file). 0002 0782 00010 addwf PCL You can see by the warning message that the default destination is the file, not the W register. Hope this helps, BAJ -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist