PIC Assembly Instruction Set | Midrange Devices

Each PIC microcontroller midrange instruction is a 14-bit word divided into an OPCODE which specifies the instruction type and one or more operands which further specify the operation of the instruction. The
midrange Instruction Set Summary in the table below lists the instructions recognized by the MPASM assembler. The instruction set is highly orthogonal and is grouped into three basic categories:

  • Byte-oriented operations
  • Bit-oriented operations
  • Literal and control operations

For byte-oriented instructions, 'f' represents a file register designator and 'd' represents a destination designator. The file register designator specifies which file register is to be used by the
instruction. The destination designator specifies where the result of the operation is to be placed. If 'd' is zero, the result is placed in the W register. If 'd' is one, the result is placed in the file register specified in the instruction.

For bit-oriented instructions, 'b' represents a bit field designator which selects the number of the bit affected by the operation, while 'f' represents the number of the file in which the bit is located.

For literal and control operations, 'k' represents an eight or eleven bit constant or literal value.

All instructions are executed in one single instruction cycle, unless a conditional test is true or the program counter is changed as a result of an instruction. In these cases, the execution takes two instruction cycles with the second cycle executed as an NOP. One instruction cycle consists of four oscillator periods. Thus, for an oscillator frequency of 4 MHz, the normal instruction execution time is 1 ms. If a conditional test is true or the program counter is changed as a result of an instruction, the instruction execution time is 2 ms.

The following instructions are applicable to midrange devices (PIC12 and PIC16)

 

BYTE-ORIENTED

FILE REGISTER OPERATIONS

ADDWF f,d
ANDWF f,d
CLRF f
CLRW
COMF f,d
DECF f,d
DECFSZ f,d
INCF f,d
INCFSZ f,d
IORWF f,d
MOVF f,d
MOVWF f,d
NOP
RLF f,d
RRF f,d
SUBWF f,d
SWAPF f,d
XORWF f,d

 

BIT-ORIENTED

FILE REGISTER OPERATIONS

BCF f,b
BSF f,b
BTFSC f,b
BTFSS f,b

 

LITERAL AND CONTROL

OPERATIONS

ADDLW k
ANDLW k
CALL k
CLRWDT
GOTO k
IORLW k
MOVLW k
RETFIE
RETLW k
RETURN
SLEEP
SUBLW k
XORLW k

[the_ad id="3059"]

Instruction Opcode Format

PIC assembly opcode format