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:
o add - additiono sub - subtractiono and - logical ando ior - logical oro xor - exclusive or
1. Copy value from/to file register or literal to/from wMnemonic Description Status Function Obs
movf fr, d Move file register Z fr => dsee macro: mov f, d
movwf fr Move W to file register w => frmacro: mov w, fr
movlw k Move literal to W k => Wmacro: movl k, w
2. Logic / arithmetic instructions with a file register and wMnemonic Description Status Function Obs
oprwf fr,dlogic / arithmetic operation with a file register and W
Z(all),C,DC (add,sub)
fr opr W => d
only add, sub affect C,DCmacro: opr fr, d
3. Logic / arithmetic instructions with a literal and wMnemonic Description Status Function Obs
oprlw klogic / arimetic operationwith a literal and W
Z(all),C,DC (add,sub)
k opr W => W
only add, sub affect C,DC macro:oprl k,w
4. One operand logic / arithmetic instructionsMnemonic 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,d1's complement file register fr
Z not fr => d
rlf fr, dRotate file register fr left thru C
CC <= fr(7), fr(i) <= fr(i-1), fr(0) <= C
rrf fr, dRotate file register fr right thru C
CC => 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 instructionsMnemonic Description Status Function Obs
goto addr branch to addr addr => PC(0:10)
call addr call routine at addrPC => TOSaddr => PC(0:10)
decfsz fr,d Decrement fr, skip if zero fr - 1 => d, skip if 0
incfsz fr,dIncrement fr, skip next instr if zero
fr + 1 => d, skip next instr if 0
btfsc fr,b Bit test fr, skip if clearskip next instr if fr(b) =0
btfss fr,b Bit test fr, skip if setskip 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 interruptTOS => PC, 1 => GIE
6. Buit-in macros for commonly used logic / arithmetic operationsMnemonic 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 Zbtfsc 3, 0 decf fr,d
negf fr, d Negate file register fr Zcomf fr, 1 incf fr,d
b addr Branch to addr goto adddr
bz addr Branch on Zero to addrbtfsc 3, 2 goto addr
bnz addrBranch on No Zero to addr
btfss 3, 2 goto addr
bc addrBranch on Carry to addr
btfsc 3, 0 goto addr
bnc addrBranch 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, fr2Exchange file regs fr1 & fr2
Z
movf fr2, 0 xorwf fr1,1xorwf fr1, 0 xorwf fr1, 1movwf fr2
Macro uses only w as temporary variableSee:mymacros.inc
decbnz fr,addrDecrement file register,if # 0 branch to addr
decfsz frgoto addr
In:mymacros.inc
Copyright © Célio Guimarães
Top Related