Free Web Hosting by Netfirms
Web Hosting by Netfirms | Free Domain Names by Netfirms


TALKING ELECTRONICS
 
PIC16F84 Data Pages
   

Previous Data Page Next Data Page

  GOTO Logic Probe   GOTO: 5x7 Display   INDEX    GOTO Basic Electronics      GOTO PIC Theory   
Only copy the data sheet:  Right mouse button:   "Save Picture As . . "
PAGE 25a

 

PIC16F84
Instruction Set

See other instruction set on P25


                                                 Destination:   0 = W    1 = F

The files in a PIC16F84 are:
                                00 to 06  
Special Purpose Registers
                                07 to 2F General Purpose Files     
   
      Note: PortA has 5 lines RA0 - RA4
(RA4 does not deliver a current - it can only sink up to 25mA)
                  PortB has 8 lines RB0 - RB7

       Blue terms are for assistance.   
"Literal" is another name for NUMBER or VALUE. It's value is 00 to FF.
        "W" is the "Working Register" (or "accumulator" - in other processors). Numbers are "Loaded" into W and from W  
          they are "MOVed" to other files. 

 ADDWF     file,0         Add W and f (result stored in W)  e.g: ADDWF 0C,0
 ADDWF     file,1         Add W and f (result stored in f)     e.g: ADDWF 0C,1
 ANDLW     00 to FF    AND Literal with W      e.g: ANDLW 40h
 ANDWF     file,0         AND W with f (result stored in W)    e.g: ANDWF 0C,0
 ANDWF     file,1         AND W with f (result stored in f)       e.g: ANDWF 0C,1
 BCF          file,bit        Bit Clear f               bit0 to bit7 i.e: 0 to 7  e.g: BCF 1E,7
 BSF          file,bit     
  Bit Set f                  bit0 to bit7 i.e: 0 to 7    e.g: BSF 1F,3
 BTFSC      file,bit        Bit Test, Skip if Clear     " "             " "      e.g: BTFSC 1A,5
 BTFSS      file,bit        Bit Test, Skip if Set       "  "            " "       e.g: BTFSS 1B,6
 CALL        label          Call Subroutine (range:00to3FF)     e.g: CALL Tone1
 CLRF        file             Clear f      e.g: CLRF 1A
 CLRW                        Clear W    =  CLRW
 CLRWDT                    Clear Watchdog Timer  =  CLRWDT
 COMF       file,0          Complement f (result stored in W)   e.g: COMF 0C,0
 COMF       file,1          Complement f (result stored in f)     e.g: COMF 0C,1
 DECF        file,0          Decrement f (result stored in W)    e.g: DECF 0D,0
 DECF        file,1          Decrement f (result stored in f)      e.g: DECF 0D,1
 DECFSZ    file,0          Decrement f, Skip if 0 (result in W)     e.g: DECFSZ 1A,0
 DECFSZ    file,1          Decrement f, Skip if 0 (result in f)        e.g: DECFSZ 1A,1 - this is the instruction to use!
 GOTO       label           Unconditional Branch (range: 000 to 3FF)    e.g: GOTO Tone2
 IN                        Read the input port: see BTFSS 05,0 or BTFSS 06,0 etc for an input-line or MOVF 05,0  MOVF 06,0
 INCF        file,0          Increment f (result stored in W)      e.g: INCF 1A,0
 INCF        file,1      
   Increment f (result stored in f)        e.g: INCF 1A,1
 INCFSZ    file,0         Increment f, Skip if 0 (result in W)   e.g: INCFSZ 1A,0
 INCFSZ    file,1          Increment f, Skip if 0 (result in f)      e.g: INCFSZ 1A,1
 IORLW     00 to FF     Inclusive OR Literal with W
       e.g: IORLW  20h
 IORWF     file,0        
  Inclusive OR W with f (result in W)     e.g: IORWF 0D,0
 IORWF     file,1          Inclusive OR W with f (result stored in f)
     e.g: IORWF 0D,1
 
LOAD                       Load a file. Use: MOVLW XX  then MOVWF 1C (or any other file)
 MOVLW    00 to FF   Move Literal to W    Load W with a number    e.g: MOVLW 80h
 MOVF       file,0         Move f (result in W)     Copy F into W     e.g: MOVF 0E,0
 MOVF       file,1         Move f (result in f) Move F in and out of F - does not put F into W   e.g: MOVF 0E,1
 MOVWF    file           Move W to f      Copy W to F     e.g: MOVWF 0C
 NOP                         No Operation       =  NOP
 OPTION                    Load OPTION Register     = OPTION
 
OR                                     see  IORWF etc. above
 OUT                        
to turn on an output. Use:  BSF 05,0 BSF 06,0 etc  or MOVF 1C,0 then MOVWF 06
 
READ                       
to Read an input line. Use: BTFSS 06,0 or BTFSS 06,1 or BTFSS 06,2 etc
 RETLW     00 to FF  
Return with Literal in W
     e.g: RETLW 80h
 RETURN                   Return from Subroutine 
      = RETURN
 RLF          file,0         Rotate Left f through Carry (result in W) Doubles the value *
      e.g: RLF 1C,0
 RLF          file,1         Rotate Left f through Carry (result in f)       "      "      "        *
     e.g: RLF 1C,1
 RRF          file,0       
  Rotate Right f through Carry (result in W) Halves the value *
     e.g: RRF 1D,0
 RRF          file,1       
  Rotate Right f through Carry (result in f)     "       "    "         *
    e.g: RRF 1D,1
 SLEEP                     Sleep
   =  SLEEP
 SUBLW    00 to FF   
Subtract W from Literal NOT subtract literal from W     e.g: SUBWF 40h
 SUBWF     file,0        Subtract W from f (result stored in W)
     e.g: SUBWF 0E,0
 SUBWF     file,1        Subtract W from f (result stored in f)
       e.g: SUBWF 0E,1
 SWAPF     file,0        Swap Nibbles in f (result stored in W)
     e.g: SWAPF 0C,0
 SWAPF     file,1        Swap Nibbles in f (result stored in f)
       e.g: SWAPF 0C,1
 TRIS        05h            Load TRISA file  from W register. Alternative: MOVLW XX then MOVWF 05. **
   (PortA - 5 lines)
 TRIS        06h         
   Load TRIS
B file  from W register. Alternative: MOVLW XX then MOVWF 06 **
    (PortB - 8 lines)
 XORLW    00 to FF    Exclusive OR Literal with W
       e.g: XORLW 40h
 XORWF    file,0         Exclusive OR W with f (result in W)
    e.g: XORWF 0C,0
 XORWF    file,1         Exclusive OR W with f (result in f)
      e.g: XORWF 0C,1

 * must clear carry before RLF or RRF if file is read. For RLF the value is doubled. For RRF the value is halved.
** must use BSF 03,5 before TRIS
for the two
alternate instructions and BCF 03,5 after the two instructions to
get into "Bank 1" where the in/out control file for the two ports is located. Use TRIS 06 for PIC12c508A

10-3-2001      Although this layout is fantastic, it is Not copyright - copy and save . . .  Colin