Talking Electronics PIC Theory
                                           

PIC12c508A 
Instruction Set


                                                   Destination: 0 = W    1 = F

The files in a '508A are:
                                 00 to 06  
Special Purpose Registers
                            07 to 1F 
General Purpose Files
     
Blue terms are for assistance.
     
Red terms are not available for the 508A.


 ADDLW      00 to FF    Add Literal and W     Not available for the '508A. See "Explaining the Instruction-Set."
 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:00 to FF) ***   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 - use this instruction
 GOTO      label           Unconditional Branch (range: 000 to 1FF)    e.g: GOTO Tone2
 IN                        Read the input port: see BTFSS 06,0 etc for an input-line or 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   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 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 - NOT available for '508A - use RETLW 00h
 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  
Not Available for the '508A 
 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        06h         
   Load TRIS file  from W register.
** Alternative: MOVLW XX then MOVWF 06  
 
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 half or double value.
** must use BSF 03,5
before TRIS (or the two equivalent instructions) and BCF 03,5 after the two instructions to get into "Bank 1" where the in/out control file for the port is located.
*** See Library of Routines for CALLs over page-boundary