PIC instruction set summary
Notation:
- fr: one of the 80 memory ram positions implemented as 8 bit registers (File Register Set or FRS) (0 =< fr <= 4f). The first 12 are special purpose registers (SFR) and the other 68 are general purpose registers(GPR).
- W: 8 bit accumulator of the Arithmetic Logic Unit (ALU)
- d: mnemonic for the destination of one operation, which can be 1 ( a file register f) or 0 (the accumulator w)
- k: an 8 bit literal
- b: 3 bit literal identifying one bit of a byte (0: least significant bit, 7: most significant bit). Example: f(7)
- addr: 11 bit literal representing an instruction address
- C: Carry bit = STATUS(0)
- Z: Zero bit = STATUS(2)
- DC: Digit Carry bit = STATUS(1)
- opr: mnemonic for one of the following binary operations:
- add - addition
- sub - subtraction
- and - logical and
- ior - logical or
- xor - exclusive or
1. Copy value from/to file register or literal to/from w Mnemonic Description Status Function Obs movf fr, d Move file register Z
fr => d macro: mov f, d movwf fr Move W to file register w => fr macro: mov w, fr movlw k Move literal to W k => W macro: movl k, w
2. Logic / arithmetic instructions with a file register and w Mnemonic Description Status Function Obs oprwf fr,d logic / arithmetic operation
with a file register and WZ(all),C,DC
(add,sub)fr opr W => d only add, sub affect C,DC
macro: opr fr, d
3. Logic / arithmetic instructions with a literal and w Mnemonic Description Status Function Obs oprlw k logic / arimetic operation
with a literal and WZ(all),C,DC
(add,sub)k opr W => W only add, sub affect C,DC
macro:oprl k,w
4. One operand logic / arithmetic instructions Mnemonic Description Status Function Obs clrw Clear accumulator W Z
0 => W clrf fr Clear file register fr Z
0 => fr decf fr,d Decrement file register fr Z
fr - 1 => d incf fr, d Increment file register fr Z
fr + 1 => d comf fr,d 1's complement file register fr Z
not fr => d rlf fr, d Rotate file register fr left thru C C
C <= fr(7), fr(i) <= fr(i-1), fr(0) <= C rrf fr, d Rotate file register fr right thru C C
C => fr(7), fr(i) => fr(i-1), fr(0) => C bcf fr, b Bit clear on file register fr 0 => fr(b) bsf fr, b Bit set on file register fr 1 => fr(b) swapf fr,d swap halves of fr (fr(0:3) <=> fr(4:7)) => d nop No operation
5. Branch, Skip and Call instructions Mnemonic Description Status Function Obs goto addr branch to addr addr => PC(0:10) call addr call routine at addr PC => TOS
addr => PC(0:10)decfsz fr,d Decrement fr, skip if zero fr - 1 => d, skip if 0 incfsz fr,d Increment fr, skip next instr if zero fr + 1 => d, skip next instr if 0 btfsc fr,b Bit test fr, skip if clear skip next instr if fr(b) =0 btfss fr,b Bit test fr, skip if set skip next instr if fr(b)=1 return return from subroutine TOS => PC retlw k return with literal in w k =>w, TOS => PC retfie return from interrupt TOS => PC, 1 => GIE
6. Buit-in macros for commonly used logic / arithmetic operations Mnemonic Description Status Function Obs addcf fr, d Add carry to fr Z
btfsc 3, 0 incf f,d subcf fr, d Subtract carry from fr Z
btfsc 3, 0 decf fr,d negf fr, d Negate file register fr Z
comf fr, 1 incf fr,d b addr Branch to addr goto adddr bz addr Branch on Zero to addr btfsc 3, 2 goto addr bnz addr Branch on No Zero to addr btfss 3, 2 goto addr bc addr Branch on Carry to addr btfsc 3, 0 goto addr bnc addr Branch on No Carry to addr btfss 3, 0 goto addr skpc Skip on Carry btfss 3, 0 skpnc Skip on No Carry btfsc 3, 0 skpz Skip on Zero btfss 3, 2 skpnz Skip on No Zero btfsc 3, 2 clrz Clear Zero flag bcf 3, 2 setz Set Zero flag bsf 3, 2 clrc Clear Carry flag bcf 3, 0 setc Set Carry flag bsf 3, 0 tstf fr Test file register fr Z
movf fr, f xchg fr1, fr2 Exchange file regs fr1 & fr2 Z
movf fr2, 0 xorwf fr1,1
xorwf fr1, 0 xorwf fr1, 1
movwf fr2Macro uses only w
as temporary variable
decbnz fr,addr Decrement file register,
if # 0 branch to addrdecfsz fr
goto addr