The Microchip name_ logo and PIC are registered trademarks of by ert554898


									    PICmicro MCU Instruction Set

   12-bit core  33 instructions
   14-bit core  35 instructions
   16-bit core  58 instructions
    Easy to learn
    High compaction
    Very powerful single-word instructions
    All single-cycle except program branches
    Upward compatibility of instructions
                PICmicro Instruction Set
        Byte-Oriented Operations                                   Bit-Oriented Operations
 NOP         -     No Operation                          BCF         f,b    Bit clear f
 MOVWF       f     Move W to f                           BSF         f,b    Bit set f
 CLRW        -     Clear W                               BTFSC       f,b    Bit test f, skip if clear
 CLRF        f     Clear f                               BTFSS       f,b    Bit test f, skip if set
 SUBWF       f,d   Subtract W from f                           Literal and Control Operations
 DECF        f,d   Decrement f
 IORWF       f,d   Inclusive OR W and f                  SLEEP       -      Go into standby mode
 ANDWF       f,d   AND W and f                           CLRWDT      -      Clear watchdog timer
 XORWF       f,d   Exclusive OR W and f                  RETLW       k      Return, place literal in W
 ADDWF       f,d   Add W and f                           RETFIE      -      Return from interrupt
 MOVF        f,d   Move f                                RETURN      -      Return from subroutine
 COMF        f,d   Complement f                          CALL        k      Call subroutine
 INCF        f,d   Increment f                           GOTO        k      Go to address (k is 9-bit)
 DECFSZ      f,d   Decrement f, skip if zero             MOVLW       k      Move literal to W
 RRF         f,d   Rotate right f through                IORLW       k      Inclusive OR literal with W
 carry                                                   ADDLW       k      Add literal with W
 RRL         f,d   Rotate left f through carry           SUBLW       k      Subtract W from literal
 SWAPF       f,d   Swap nibbles of f                     ANDLW       k      AND literal with W
 INCFSZ      f,d   Increment f, skip if zero             XORLW       k      Exclusive OR literal with W

f = File Register, k = literal value (8-bit), b = bit address <0,7>, d = destination (0=f, 1=W)
          PICmicro Instruction Set
                 Byte-Oriented Operations
NOP        -
                       14-bit Instruction for Byte Oriented Operations
MOVWF      f
CLRW       -
CLRF       f               OP CODE             d   f f f f f f f
SUBWF      f,d
DECF       f,d
IORWF      f,d
                    d = Destination Bit
ANDWF      f,d       d = 0 for destination W
XORWF      f,d
                     d = 1 for destination f
ADDWF      f,d
MOVF       f,d
COMF       f,d      f = 7-bit Register Address
INCF       f,d
DECFSZ     f,d
RRF        f,d
RRL        f,d         Example:
                       ADDWF           REG, W
                       ADDWF           f, d
         PICmicro Instruction Set
               Bit-Oriented Operations
Operations         14-bit Instruction for Bit Oriented Operations

 BCF   f,b          OP CODE        b b b    f f f f f f f
 BSF   f,b
 BTFSC f,b
 BTFSS f,b        b = 3-Bit Address
                    (Bit Number)

                    f = 7-bit Register Address

                  BTFSC            STATUS, C
                  BTFSC            f, b
           PICmicro Instruction Set
           Literal and Control Operations
Literal and Control
    Operations          14-bit Instruction for Literal Operations
  SLEEP     -
  CLRWDT    -            OP CODE          k k k k k k k k
  RETLW     k
  RETFIE    -
  RETURN    -         k = 8-bit Immediate Value
  CALL      k
  GOTO      k
  MOVLW     k
  IORLW     k
  ADDLW     k
  SUBLW     k
  ANDLW     k            MOVLW 0x2F
  XORLW     k            MOVLW       k
         PICmicro MCU Instruction Set
                  Example: Bit Manipulation
       Synchronous serial transmission of eight bits of
        data from file register XDATA to I/O Pin:
XMIT:         MOVLW        0x08          ;Bit count = 8
              MOVWF        bit_count
              BCF          PORTB,DT      ;preset clock & data lines to 0
              BCF          PORTB,CLK     ;preset clock & data lines to 0
              RRF          XDATA,F       ;rotate data right thru Carry
              BTFSC        STATUS,C      ;test carry bit
              BSF          PORTB,DT      ;set 1  Data pin
              BSF          PORTB,CLK     ;set 1  Clock pin
              DECFSZ       bit_count,F   ;decrement count
              GOTO         XM_LOOP       ;Not done then repeat
              BCF          PORTB,CLK     ;clear clock line and exit
              0        1                   7
                         Instruction Set
    Bit Manipulation Performance Comparison
PIC16CXX                              MC68HC05
XMIT      movlw     0x08              XMIT     LDA     XDATA
          movwf     BIT_COUNT, F               LDX     #$08
          bcf       PORTB, DT
XM_LOOP                                      BCLR      0, PORTB
       bcf          PORTB, CLK               BCLR      1, PORTB
       rrf          XDATA, F                 ROLA
       btfsc        STATUS, C                BCC       XM1
       bsf          PORTB, DT                BSET      1, PORTB
       bsf          PORTB, CLK               BSET      0, PORTB
       decfsz       BIT_COUNT, F             DECX
       goto         XM_LOOP                  BNE       XM_LOOP
       bcf          PORTB, CLK               BCLR      0, PORTB
   11 words of program memory
                                         20 bytes of program memory
   74 cycles = 14.8µS @ 20MHz
   Equivalent bit rate of 540 kbps      266 cycles = 126.7µS @ 4.2MHz
   @ 4.2MHz = 113.4 kbps                Equivalent bit rate of 63 kbps
   @ 63 kbps = 2.33MHz
         14-Bit Core Instruction Set

    instructions on 14 bit core devices.
   The following instructions are not in
    the 12 bit core:
    – ADDLW -- Add literal k to contents of W
    – RETFIE -- Return from interrupt
      subroutine (Enables GIE bit)
    – RETURN --Return from subroutine (No
      effect on GIE bit)

                Microchip Introduction 2000
               14-Bit Core Instruction Set
   ADDWF f,d; d=0 or d=1
   Operands: 0=<f=<127
   Operation: (W)+(f)--->(dest)
   Status Affected: C, DC, Z
   Encoding: 00 | 0111 | dfff | ffff
   Description: Add contents of W to contents of
    register f.
   e.g. Before instruction After instruction
    W=0x17, FSR=0xC2         W=0xD9, FSR=0xC2
   Words=1, Cycles=1

                     Microchip Introduction 2000
             14-Bit Core Instruction Set
                               CALL k
    Operands: 0=<k=<2047
    Operation: (PC)+1--->TOS, k--->PC<10:0>,
    Encoding: 10 | 0kkk | kkkk | kkkk
    Description: Call subroutine. First, return address PC+1 is
     pushed onto the stack.
    Words 1, Cycles 2
     Before instruction                     After instruction
         TOS= unknown                        TOS=PC+1
     PC = Address (HERE+1)                   PC= Address THERE

                         Microchip Introduction 2000

To top