Searching \ for 'What's the difference between d and f?' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/index.htm?key=whats+difference
Search entire site for: 'What's the difference between d and f?'.

Truncated match.
PICList Thread
'What's the difference between d and f?'
1998\10\25@120253 by Robert Jordan

picon face
I've always been confused about this.  The PIC16F84 manual states that
certain operations use a "d" option in the opcode field.

For example,

MOVF    FSR, 0          ;Moves the value in FSR to W and sets the Z bit

But I see ALL programming examples using the syntax

MOVF    FSR, W

What is the difference?  The PIC manual says the format of the
instruction is

[label] MOVF    f,d

Where d is a member of the set (0,1).  W isn't a 0 or 1.  Is something
going on inside the MPASM compiler that the MicroChip manuals don't
bother to mention?  Or am I just missing something obvious?

Thanks,
Robert

1998\10\25@124653 by Harold M Hallikainen

picon face
On Sun, 25 Oct 1998 09:03:58 -0800 Robert Jordan <spam_OUTxlTakeThisOuTspamHOME.COM> writes:
{Quote hidden}

       I think that the include file that defines the Special Function
Registers for a particular processor ALSO has the definition of W as 0
and F as 1, so the assembler does the substitution.  I'm in the habit of
just using 0 or 1.  Also, instead of using MOV f,d, I use MOVFW instead
of MOV F,0 and TSTF instead of MOV F,1 .

Harold


___________________________________________________________________
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com/getjuno.html
or call Juno at (800) 654-JUNO [654-5866]

1998\10\25@214030 by Robert Jordan

picon face
I'll be damned!  There it is...

16C84.inc exerpt from the MPLAB header files...
;==========================================================================

       IFNDEF __16C84
          MESSG "Processor-header file mismatch.  Verify selected
processor."
       ENDIF

;==========================================================================
;
;       Register Definitions
;
;==========================================================================

W                            EQU     H'0000'
F                            EQU     H'0001'

;----- Register
Files------------------------------------------------------

INDF                         EQU     H'0000'
TMR0                         EQU     H'0001'
PCL                          EQU     H'0002'
STATUS                       EQU     H'0003'
FSR                          EQU     H'0004'
.
.
.
;--------------------------------------------------------------------------

SImple enough and now I see what is going on with all of those source
files!

Thanks,
Robert


Harold M Hallikainen wrote:
{Quote hidden}

1998\10\26@053206 by Russell McMahon

picon face
Robert


Simple concept. Harder to explain.
Many PIC instructions can two possible destinations which you can
select between for the results of the operation. These are either
0    The W register or
1    The register which sourced the original data.
In such cases the instruction sequence is suffixed either with a 0 if
you want the data to end up in W or with a 1 if you want the data to
end up back in the register you started out with.
An example will (hopefully) make this clearer.

   movlw        5                    Place a 5 in W
   MOVWF    counter        Move the 5 into "COUNTER"
   movlw        1                    Place a 1 in W
   addwf        counter, 1    Add W to COUNTER
                                           Place the result in
COUNTER

In the line "addwf   counter,1" the final "1" told the PIC to add the
results of the add into COUNTER
ie 5+1=6. Place the 6 in counter. W will still contain "1".

If the instruction had read "addwf  counter,0" then the result would
have been placed in W. W would now contain "6" and COUNTER will still
contain "5"

This is a real part of the PIC instruction - not just an assembler
trick.


       Russell McMahon


{Original Message removed}

1998\10\26@093015 by brah

flavicon
face
Robert Jordan wrote:
{Quote hidden}

I believe d is for destination (register)

1998\10\26@093700 by brah

flavicon
face
{Quote hidden}

I've used f instead of 1
e.g.
       movlw   0x10
       movwf   counter
       incfsz  counter,f
Seems to work OK with Mplab. Am I lucky or correct?

Regards Howard

1998\10\26@114958 by Michael Hagberg

flavicon
face
in the processor include file the register are defined
;==========================================================================
;
;       Register Definitions
;
;==========================================================================

W                            EQU     H'0000'
F                            EQU     H'0001'

;----- Register Files------------------------------------------------------

INDF                         EQU     H'0000'
TMR0                         EQU     H'0001'
PCL                          EQU     H'0002'
STATUS                       EQU     H'0003'
FSR                          EQU     H'0004'
PORTA                        EQU     H'0005'
PORTB                        EQU     H'0006'
EEDATA                       EQU     H'0008'
EEADR                        EQU     H'0009'
PCLATH                       EQU     H'000A'
INTCON                       EQU     H'000B'

this means the the assembler will see the following as all alike.
   movf    5,0
   movf    5,W
   movf    porta,0
   movf    porta,w    ; this is the easiest to understand

michael

You may leave the list at any time by writing "SIGNOFF PICLIST" in the
   body of a message to LISTSERVspamKILLspamMITVMA.MIT.EDU.

{Original Message removed}

More... (looser matching)
- Last day of these posts
- In 1998 , 1999 only
- Today
- New search...