Commend list for MPLABx

This is a list of instructions usefull to program dspic.

Instruction Description Operation Flag CLK *
Data Transfer Instructions
MOVLW k Move constant to W k -> w 1
MOVWF f Move W to f W -> f 1
MOVF f,d Move f to d f -> d Z 1 1, 2
CLRW Clear W 0 -> W Z 1
CLRF f Clear f 0 -> f Z 1 2
SWAPF f,d Swap nibbles in f f(7:4),(3:0) -> f(3:0),(7:4) 1 1, 2
Arithmetic-logic Instructions
ADDLW k Add W and constant W+k -> W C, DC, Z 1
ADDWF f,d Add W and f W+f -> d C, DC ,Z 1 1, 2
SUBLW k Subtract W from constant k-W -> W C, DC, Z 1
SUBWF f,d Subtract W from f f-W -> d C, DC, Z 1 1, 2
ANDLW k Logical AND with W with constant W AND k -> W Z 1
ANDWF f,d Logical AND with W with f W AND f -> d Z 1 1, 2
ANDWF f,d Logical AND with W with f W AND f -> d Z 1 1, 2
IORLW k Logical OR with W with constant W OR k -> W Z 1
IORWF f,d Logical OR with W with f W OR f -> d Z 1 1, 2
XORLW k Logical exclusive OR with W with constant W XOR k -> W Z 1 1, 2
XORWF f,d Logical exclusive OR with W with f W XOR f -> d Z 1
INCF f,d Increment f by 1 f+1 -> f Z 1 1, 2
DECF f,d Decrement f by 1 f-1 -> f Z 1 1, 2
RLF f,d Rotate left f through CARRY bit C 1 1, 2
RRF f,d Rotate right f through CARRY bit C 1 1, 2
COMF f,d Complement f f -> d Z 1 1, 2
Bit-oriented Instructions
BCF f,b Clear bit b in f 0 -> f(b) 1 1,2
BSF f,b Set bit b in f 1 -> f(b) 1 1,2
Program Control Instructions
BTFSC f,b Test bit b of f. Skip the following instruction if clear. Skip if f(b) = 0 1 (2) 3
BTFSS f,b Test bit b of f. Skip the following instruction if set. Skip if f(b) = 1 1 (2) 3
DECFSZ f,d Decrement f. Skip the following instruction if clear. f-1 -> d skip if Z = 1 1 (2) 1, 2, 3
INCFSZ f,d Increment f. Skip the following instruction if set. f+1 -> d skip if Z = 0 1 (2) 1, 2, 3
GOTO k Go to address k -> PC 2
CALL k Call subroutine PC -> TOS, k -> PC 2
RETURN Return from subroutine TOS -> PC 2
RETLW k Return with constant in W k -> W, TOS -> PC 2
RETFIE Return from interrupt TOS -> PC, 1 -> GIE 2
Other instructions
NOP No operation TOS -> PC, 1 -> GIE 1
CLRWDT Clear watchdog timer 0 -> WDT, 1 -> TO, 1 -> PD TO, PD 1
SLEEP Go into sleep mode 0 -> WDT, 1 -> TO, 0 -> PD TO, PD 1
Instruction Description Equivalent Instruction Status Affected
ADDCF f,d Add with carry BTFSC
INCF
STATUS,C
ADDDCF f,d Add with Digit Carry BTFSC
INCF
STATUS,DC
B k Branch GOTO
BC k Branch on Carry BTFSC
GOTO
STATUS,C
BDC k Branch on Digit Carry BTFSC
GOTO
STATUS,DC
BNC k Branch on No Carry BTFSS
GOTO
STATUS,C
BNDC k Branch on No Digit Carry BTFSS
GOTO
STATUS,DC
BNZ k Branch on No Zero BTFSS
GOTO
STATUS,Z
BZ k Branch on Zero BTFSC
GOTO
STATUS,Z
CLRC Clear Carry BCF STATUS,C
CLRDC Clear Digit Carry BCF STATUS,DC
CLRZ Clear Zero BCF STATUS,Z
MOVFW f Move File to W MOVF
SETC f Set Carry BSF STATUS,C
SETDC Set Digit Carry BSF STATUS,DC
SETZ Set Zero BSF STATUS,Z
SKPC Skip on Carry BTFSS STATUS,C
SKPDC Skip on Digit Carry BTFSS STATUS,DC
SKPNC Skip on No Carry BTFSC STATUS,Z
SKPNDC Skip on No Digit Carry BTFSC STATUS,DC
SKPNZ Skip on Non Zero BTFSC STATUS,Z
SKPZ Skip on Zero BTFSS STATUS,Z
SUBCF f, d Subtract Carry from File BTFSC
DECF
STATUS,C
SUBDCF f, d Subtract Digit Carry from File BTFSC
DECF
STATUS,DC
TSTF f Test File MOVF

Those came from http://www.mikroe.com/chapters/view/10/chapter-9-instruction-set/

Leave a Reply

Your email address will not be published. Required fields are marked *