You are on page 1of 1

Microchip PIC Assembly Language: Table of Instruction Mnemonics & Their Functions

Instruction
ADDLW
ADDWF
ANDLW
ANDWF
BCF
BSF
BTFSC
BTFSS
CALL
CLRF
CLRW
CLRWDT
COMF
DECF
DECFSZ
GOTO
INCF
INCFSZ
IORLW
IORWF
MOVF
MOVLW
MOVWF
NOP
RETFIE
RETLW
RETURN
RLF
RRF
SLEEP
SUBLW
SUBWF
SWAPF
XORLW
XORWF

Cycles
1
1
1
1
1
1
2
2
2
1
1
1
1
1
2
2
1
2
1
1
1
1
1
1
2
2
2
1
1
1
1
1
1
1
1

Form
ADDLW k
ADDWF f,d
ANDLW k
ANDWF f,d
BCF f,b
BSF f,b
BTFSC f,b
BTFSS f,b
CALL k
CLRF f
CLRW
CLRWDT
COMF f,d
DECF f,d
DECFSZ f,d
GOTO k
INCF f,d
INCFSZ f,d
IORLW k
IORWF f,d
MOVF f,d
MOVLW k
MOVWF f
NOP
RETFIE
RETLW k
RETURN
RLF f,d
RRF f,d
SLEEP
SUBLW k
SUBWF f,d
SWAPF f,d
XORLW k
XORWF f,d

Function
W=W+k
d=0
W=W+f
d =1
f=f+W
W = W AND k
d =1
f = f AND W
d=0
W = W AND f
CLEAR bit b of register f
SET bit b of register f
SKIP next line if bit b of register f is clear ( = 0 )
SKIP next line if bit b of register f is set ( = 1 )
CALL subroutine that starts at memory location k (move to line after CALL when RETURN is reached in subroutine)
Clear memory location f and set Z bit (bit 2) of STATUS register
Clear W register and set Z bit (bit 2) of STATUS register
Reset (CLEAR) Watchdog Timer, reset prescaler of WDT
d=0
W = 1s compliment of f
d=1
f = 1s compliment of f
d=0
W=f -1
d=1
f=f-1
d=0
W = f - 1, Next line skipped if result = 0
d=1
f = f - 1, Next line skipped if result = 0
Jump (GOTO) to address k
d=0
W=f+1
d=1
f=f+1
d=0
W = f + 1, Next line skipped if result = 0
d=1
f = f + 1, Next line skipped if result = 0
W = W OR k
d=1
f = f OR W
d=0
W = W OR f
d=0
W=f
d=1
f = f (useful to test a file register)
W=k
f=W
No Operation (Useful for killing time or for subroutine place holders)
Return From Interrupt
RETURN from subroutine with k in W (Put this at the end of a subroutine where you need to return a number back)
Jump to the line of code that is immediately after the line that this subroutine was called from
d=0
W = f rotated 1 bit to the left through C flag
d=1
f = f rotated 1 bit to the left through C flag
d=0
W = f rotated 1 bit to the right through C flag d = 1
f = f rotated 1 bit to the right through C flag
Puts PIC into SLEEP mode with the oscillator stopped (00h
WDT, 0
WDT prescaler)
W=k-W
d=0
W=f-W
d=1
f =f-W
d=0
W = f with nibbles swapped (i.e. 4E
E4)
d=1
f = f with nibbles swapped (i.e. 4E
E4)
W = W XOR k
d=0
W = W XOR f
d=1
f = W XOR f

__ __
* (?, ?) = ( TO, PD )
W
f
k
d
b

The W register (or accumulator) is used as temporary storage for many instructions
f represents a user defined variable or a system memory location
k represents a literal number or a defined constant
The value of d (0 or 1) determines where the numerical result of an operation will be stored (if d = 0 then result in W, if d = 1 then result in f)
b represents a particular bit in an 8-bit memory location ( 7, 6, 5, 4, 3, 2, 1, 0 )

Status Affected
C, DC, Z
C, DC, Z
Z
Z
none
none
none
none
none
Z
Z
!TO, !PD (1,1)*
Z
Z
none
none
Z
none
Z
Z
Z
none
none
none
none
none
none
C
C
!TO, !PD (1,0)*
C, DC, Z
C, DC, Z
none
Z
Z

You might also like