Академический Документы
Профессиональный Документы
Культура Документы
CONTROL DIRECTIVES
CONSTANT #DEFINE END EQU ERROR ERRORLEVEL #INCLUDE LIST MESSG NOLIST ORG PAGE Declare Symbol Constant constant <label> [= <expr>, ...,<label> [= <expr>] ] Define Text Substitution End Program Block #define <name> [[(<arg>,...,<arg>)]<value>] end
Define Assembly Constant <label> equ <expr> Issue an Error Message Set Messge Level Include Source File Listing Options User Defined Message Turn off Listing Output Set Program Origin Insert Listing Page Eject error "<text_string>" errorlevel 0|1|2|<+-><msg> include <<include_file>> include "<include_file>" list [<option>[,...,<option>]] messg "<message_text>" nolist <label> org <expr> page processor <processsor_type> radix <default_radix> <label> set <expr> space [<expr>] subtitl "<sub_text>" title "<title_text>" #undefine <label> variable <label> [= <expr>,...,]
PROCESSOR Set Processor Type RADIX SET SPACE SUBTITLE TITLE #UNDEFINE VARIABLE Specify Default Radix Assign Value to Variable Insert Blank Listing Lines Specify Program Subtitle Specify Program Title Delete a Substitution Label Declare Symbol Variable
CONDITIONAL ASSEMBLY
ELSE ENDIF ENDW IF IFDEF IFNDEF WHILE Begin Alternative Assem- else bly to IF End Conditional Assembly endif End a While Loop Begin Conditional ASM Code endw if <expr>
Execute If Symbol Defined ifdef <label> Execute If Symbol Not Defined Perform Loop While True ifndef <label> while <expr>
Description
Syntax
Create Numeric/Text Data data <expr>,[,<expr>,...,<expr>] data "<text_string>"[,"<text_string>",...] Declare Data of One Byte db <expr>[,<expr>,...,<expr>] Declare EEPROM Data Define Table de <expr>[,<expr>,...,<expr>] dt <expr>[,<expr>,...,<expr>]
Specify Memory Fill Value fill <expr>, <count> Set ID locations Specify max RAM adr Reserve Memory _ _idlocs <expr> _ _maxram <expr> res <mem_units>
MACROS
ENDM EXITM EXPAND LOCAL MACRO NOEXPAND End a Macro Definition Exit from a Macro Expand Macro Listing endm exitm expand
Declare Local Macro Vari- local <label> [,<label>] able Declare Macro Definition <label> macro [<arg>,...,<arg>]
Syntax
D<digits>' .<digits> H<hex_digits>' 0x<hex_digits> O<octal_digits>' B<binary_digits>' <character>' A<Character>' D100' .100 H9f' 0x9f O777'
Example
Description
Specify output file filename. Default is a.out. Create map file filename. Add directories to library search path. Add directories to linker script search path. Specify number of lines per listing page. Display help screen. Specify format of hex output file. Quiet mode. Dont create an absolute listing file.
Description
Bit address within an 8 bit file register Store result in W (f0A). Store result in file register f. Default is d = 1.
f k W x i p t PH:PL
Register file address (0x00 to 0xFF) Literal field, constant data or label Working register (accumulator) Dont care location Table pointer control; i = 0 i=1 Do not change. Increment after instruction execution.
Peripheral register file address (0x00 to 0x1f) Table byte select; t=0 t=1 Perform operation on lower byte. Perform operation on upper byte.
Mnemonic
ANDLW CALL CLRWDT GOTO IORLW MOVLW OPTION RETLW SLEEP TRIS XORLW f k k k k k k k
Description
AND literal and W Call subroutine Clear watchdog timer Goto address (k is 9 bits) Incl. OR literal and W Move Literal to W Load OPTION Register Return with literal in W Go into Standby Mode Tristate port f
Function
k .AND. W W PC + 1 TOS, k PC 0 WDT (and Prescaler if assigned) k PC(9 bits) k .OR. W W kW W OPTION Register k W, TOS PC 0 WDT, stop osc W I/O control reg f
Mnemonic
ADDWF ANDWF CLRF CLRW COMF DECF DECFSZ INCF INCFSZ IORWF MOVF MOVWF NOP RLF RRF SUBWF SWAPF XORWF f,d f,d f,d f,d f,d f,d f,d f,d f,d f,d f,d f,d f f,d f,d f
Description
Add W and f AND W and f Clear f Clear W Complement f Decrement f Decrement f, skip if zero Increment f Increment f, skip if zero Inclusive OR W and f Move f Move W to f No operation Rotate left f
C
Function
W+f d W .AND. f d 0f 0W .NOT. f d f-1d f - 1 d, skip if zero f+1d f + 1 d, skip if zero W .OR. f d fd Wf
register f 7......0 register f C 7......0
Mnemonic
BCF BSF BTFSC BTFSS f,b f,b f,b f,b
Description
Bit clear f Bit set f Bit test, skip if clear Bit test, skip if set
Function
0 f(b) 1 f(b) skip if f(b) = 0 skip if f(b) = 1
Mnemonic
ADDLW ANDLW CALL k k k
Description
Add literal to W AND literal and W Call subroutine Clear watchdog timer
Function
k+W W k .AND. W W PC + 1 TOS, k PC 0 WDT (and Prescaler) k .OR. W W kW W OPTION Register TOS PC, 1 GIE k W, TOS PC TOS PC 0 WDT, stop oscillator k-WW W I/O control reg f k .XOR. W W
CLRWDT T GOTO IORLW MOVLW OPTION RETFIE RETLW RETURN SLEEP SUBLW TRIS XORLW k f k k k k k
Goto address (k is nine bits) k PC(9 bits) Incl. OR literal and W Move Literal to W Load OPTION register Return from Interrupt Return with literal in W Return from subroutine Go into Standby Mode Subtract W from literal Tristate port f Exclusive OR literal and W
Mnemonic
ADDWF ANDWF CLRF CLRW COMF DECF DECFSZ INCF INCFSZ IORWF MOVF MOVWF NOP RLF f,d f,d f,d f,d f,d f,d f,d f,d f f,d f,d f
Description
Add W and f AND W and f Clear f Clear W Complement f Decrement f Decrement f, skip if zero Increment f Increment f, skip if zero Inclusive OR W and f Move f Move W to f No operation Rotate left f
C
Function
W+fd W .AND. f d 0f 0W .NOT. f d f - 1 d f - 1 d, skip if 0 f+1d f + 1 d, skip if 0 W .OR. f d fd Wf
register f 7 .. .. .. 0
0Cff
RRF
f,d
Rotate right f
C
register f 7 .. .. .. 0
Subtract W from f Swap halves f Exclusive OR W and f Bit clear f Bit set f Bit test, skip if clear Bit test, skip if set
f-Wd f(0:3) f(4:7) d W .XOR. f d 0 f(b) 1 f(b) skip if f(b) = 0 skip if f(b) = 1
Description
Add Carry to File Add Digit Carry to File Branch Branch on Carry Branch on Digit Carry
Equivalent Operation(s)
BTFSC INCF BTFSC INCF GOTO BTFSC GOTO BTFSC GOTO 3,0 f,d 3,1 f,d k 3,0 k 3,1 k 3,0 k 3,1 k 3,2 k 3,2 k 3,0 3,1 3,2 0x0A,3 0x0A,4 k 0x0A,3 0x0A,4 k f,0 f,1 f,d 3,0 3,1 3,2 3,0 3,1 3,0 3,1 3,2 3,2 3,0 f,d 3,1 f,d f,1
Status
Z Z
Branch on No Carry BTFSS GOTO Branch on No Digit Carry Branch on No Zero Branch on Zero Clear Carry Clear Digit Carry Clear Zero Long Call BTFSS GOTO BTFSS GOTO BTFSC GOTO BCF BCF BCF BCF/BSF BCF/BSF CALL BCF/BSF BCF/BSF GOTO MOVF COMF INCF BSF BSF BSF BTFSS BTFSS BTFSC BTFSC BTFSC BTFSS BTFSC DECF BTFSC DECF MOVF
LGOTO
Long GOTO
Z Z Z Z Z
MOVFW NEGF SETC SETDC SETZ SKPC SKPDC SKPNC SKPNDC SKPNZ SKPZ SUBCF SUBDCF TSTF
f f,d
Move File to W Negate File Set Carry Set Digit Carry Set Zero Skip on Carry Skip on Digit Carry Skip on No Carry Skip on No Digit Carry Skip on Non Zero Skip on Zero
f,d f,d f
Subtract Carry from File Subtract Digit Carry from File Test File
Microchip Technology Inc. 2355 West Chandler Blvd. Chandler, AZ 85224 Tel: 480.786.7200 Fax: 480.899.9210 Web Site Address: www.microchip.com The Microchip and logo, PIC, and PICmicro are registered trademarks of Microchip Technology Incorporated in the U.S.A. and other countries. MPLAB is a trademark of Microchip Technology in the U.S.A. and other countries. 1999 Microchip Technology Incorporated. All rights reserved. Printed in the U.S.A. 4/99 DS30400D
Mnemonic
MOVFP f,p k k p,f f
Description
Move f to p Move literal to BSR Move literal to RAM page select Move p to f Move W to F fp
Function
k BSR (3:0) k BSR (7:4) pW Wf TBLATH f if t=1, TBLATL f if t=0; ProgMem(TBLPTR) TBLAT; TBLPTR + 1 TBLPTR if i=1
b8kk MOVLB bakx MOVLP 4pff 01ff a8ff MOVPF MOVWF TABLRD
t,i,f Read data from table latch into file f, then update table latch with 16-bit contents of memory location addressed by table pointer t,i,f Write data from file f to table latch and then write 16-bit table latch to program memory location addressed by table pointer t,f Read data from table latch into file f (table latch unchanged)
acff
TABLWT
a0ff
TLRD
TBLATH f if t = 1 TBLATL f if t = 0
a4ff
TLWT
t,f
Mnemonic
k f,d f,d k f,d f,d f,d f,d f,d f,d k f,d k k f f,d f,d ADDWF ADDWFC
Description
Add literal to W Add W to F Add W and Carry to f AND Literal and W AND W with f Clear f and Clear d Complement f Dec. adjust W, store in f,d Decrement f Increment f Inclusive OR literal with W Inclusive or W with f Move literal to W Multiply literal and W Multiply W and f Negate W, store in f and d Rotate left through carry
C
Function
(W + k) W (W + f) d (W + f + C) d (W .AND. k) W (W .AND. f) d 0x00 f,0x00 d .NOT. f d W adjusted f and d (f - 1) f and d (f + 1) f and d (W .OR. k) W (W .OR. f) d kW (k x W) PH:PL (W x f) PH:PL (W + 1) f,(W + 1) d
register f 7 .. .. .. 0
b1kk ADDLW
b5kk ANDLW 0aff 28ff 12ff 2eff 06ff 14ff ANDWF CLRF COMF DAW DECF INCF
b0kk MOVLW bckk MULLW 34ff 2cff 1aff MULWF NEGW RLCF
Mnemonic
RLNCF f,d
Description
Rotate left (no carry)
Function
register f 7 .. .. .. 0 register f 7. .. .. .0 register f 7 .. .. .. 0
18ff
RRCF
f,d
20ff
RRNCF
f,d
2aff
SETF
Set f and Set d Subtract W from literal Subtract W from f Subtract from f with borrow Swap f
Mnemonic
BCF BSF BTFSC BTFSS BTG f,b f,b f,b f,b f,b
Description
Bit clear f Bit set f Bit test, skip if clear Bit test, skip if set Bit toggle f 1 f(b)
Function
0 f(b) skip if f(b) = 0 skip if f(b) = 1 .NOT. f(b) f(b)
Description
Subroutine call (within 8k page) Compare f/w, skip if f = w Compare f/w, skip if f > w Compare f/w, skip if f< w Decrement f, skip if 0 Decrement f, skip if not 0 Unconditional branch (within 8k) Increment f, skip if zero
Function
PC+1 TOS,k PC(12:0), k(12:8) PCLATH(4:0), PC(15:13) PCLATH(7:5) f-W, skip if f = W f-W, skip if f > W f-W, skip if f < W (f-1) d, skip if 0 (f-1) d, skip if not 0 k PC(12:0) k(12:8) PCLATH(4:0), PC(15:13) PCLATH(7:5) (f+1) d, skip if 0 (PC+1) TOS; k PCL, (PCLATH) PCH (PCLATH) PCH:k PCL 0 GLINTD k W, TOS PC, (PCLATH unchanged)
ekkk CALL
f f f f,d f,d k
1eff 24ff
INCFSZ INFSNZ
f,d f,d k
Increment f, skip if not zero (f+1) d, skip if not 0 Long Call (within 64k) Return from interrupt, enable interrupt
Function
TOS PC (PCLATH unchanged) skip if f = 0
Function
0 WDT,0 WDT prescaler, 1 PD, 1 TO Stop oscillator,power down, 0 WDT, 0 WDT Prescaler 1 PD, 1 TO
Description
LITERALS
kk kb kc kd 8-bit literal value 4-bit literal value bits 8-11 of 12-bit literal value bits 0-7 of 12-bit literal value
OFFSETS, ADDRESSES
nn nd ml mm 8-bit relative offset (signed, 2s complement) 11-bit relative offset (signed, 2s complement) bits 0-7 of 20-bit program memory address bits 8-19 of 20-bit program memory address
BITS
b d a s bits 9-11; bit address bit 9; 0=W destination; 1=f destination bit 8; 0=access block; 1=BSR selects bank bit 0 (bit 8 for CALL); 0=no update; 1(fast)=update/save W, STATUS, BSR
Mnemonic
ADDLW ANDLW CLRWD kk kk
Description
ADD literal to WREG
Function
W+kk W 0 WDT, 0 WDT postscaler, 1 TO,1 PD
0007
DAW
Decimal Adjust WREG if W<3:0> >9 or DC=1, W<3:0>+6W<3:0>, else W<3:0> W<3:0>; if W<7:4> >9 or C=1, W<7:4>+6W<7:4>, else W<7:4> W<7:4>; kk r,kd:kc kb kk kk kk kk Inclusive OR literal with W .OR. kk W WREG Load 12-bit Literal to FSR (second word) Move literal to low nibble in BSR Move literal to WREG Multiply literal with WREG Subtract W from literal Exclusive OR literal with WREG kd:kc FSRr kb BSR kk W W * kk PRODH:PRODL kkW W W .XOR. kk W
Mnemonic
TBLRD* TBLRD*+
Description
Function
Table Read (no change Prog Mem to TBLPTR) (TBLPTR) TABLAT Table Read (post-increment TBLPTR) Table Read (post-decrement TBLPTR) Table Read (pre-increment TBLPTR) Prog Mem (TBLPTR) TABLAT TBLPTR +1 TBLPTR Prog Mem (TBLPTR) TABLAT TBLPTR -1 TBLPTR TBLPTR +1 TBLPTR Prog Mem (TBLPTR) TABLAT
000A
TBLRD*-
000B
TBLRD+*
000C 000D
TBLWT* TBLWT*+
Table Write (no change TABLAT Prog to TBLPTR) Mem(TBLPTR) Table Write (post-increment TBLPTR) Table Write (post-decrement TBLPTR) Table Write (pre-increment TBLPTR) TABLAT Prog Mem(TBLPTR) TBLPTR +1 TBLPTR TABLAT Prog Mem(TBLPTR) TBLPTR -1 TBLPTR TBLPTR +1 TBLPTR TABLAT Prog Mem(TBLPTR)
000E
TBLWT*-
000F
TBLWT+*
Mnemonic
nn nn nn nn nn nn nn nd nn
Description
Relative Branch if Carry Relative Branch if Negative
Function
if C=1, PC+2+2*nn PC, else PC+2PC if N=1, PC+2+2*nnPC,else PC+2PC
Relative Branch if Not if C=0, PC+2+2*nnPC, Carry else PC+2PC Relative Branch if Not if N=0, PC+2+2*nnPC, Negative else PC+2PC Relative Branch if Not if OV=0, PC+2+2*nnPC, Overflow else PC+2PC Relative Branch if Not if Z=0, PC+2+2*nnPC, Zero else PC+2PC Relative Branch if Overflow if OV=1, PC+2+2*nnPC, else PC+2PC
D0 nd BRA E0nn BZ
Unconditional relative PC+2+2*nd PC branch Relative Branch if Zero if Z=1, PC+2+2*nnPC, else PC+2PC PC+4 TOS, mm:ml PC<20:1>, if s=1, W WS, STATUS STATUSS, BSR BSRS mm:ml PC<20:1> No operation TOS-1 TOS PC +2 TOS PC+2 TOS, PC+2+2*ndPC
mm:ml
nd
Generate a Reset same as MCLR reset (same as MCR reset) s Return from interrupt (and enable interrupts) TOS PC, 1 GIE/GIEH or PEIE/GIEL, if s=1, WS W, STATUSS STATUS, BSRS BSR, PCLATU/PCLATH unchngd.
0C kk 0012
RETLW
kk
Return from kk W subroutine, literal in W Return from subroutine TOS PC, if s=1, WS W, STATUSS STATUS, BSRS BSR, PCLATU/PCLATH are unchanged 0 WDT, 0 WDT postscaler, 1 TO, 0 PD
RETURN s
0003
SLEEP
Mnemonic
BCF BSF BTFSC BTFSS BTG f,b,a f,b,a f,b,a f,b,a f,b,a
Description
Bit Clear f Bit Set f Bit test f, skip if clear Bit test f, skip if set Bit Toggle f
Function
0 f<b> 1 f<b> if f<b>=0, PC+4PC, else PC+2PC if f<b>=1, PC+4PC, else PC+2PC f<b> f<b>
Mnemonic
ADDWF f,d,a ADDWFC f,d,a
Description
ADD WREG to f ADD WREG and Carry bit to f
Function
W+f dest W+f+C dest W .AND. f dest 0f f dest fW, if f=W, PC+4 PC else PC+2 PC fW, if f > W, PC+4 PC else PC+2 PC fW, if f < W, PC+4 PC else PC+2 PC f1 dest f1 dest, if dest=0, PC+4 PC else PC+2 PC f1 dest, if dest 0, PC+4 PC else PC+2 PC f+1 dest f+1 dest, if dest=0, PC+4 PC else PC+2 PC f+1 dest, if dest 0, PC+4 PC else PC+2 PC W .OR. f dest f dest fs fd Wf W * f PRODH:PRODL f + 1 PRODH:PRODL
C register f 7 .. .. .. 0
register f 7......0
AND WREG with f Clear f Complement f Compare f with WREG, skip if f=WREG Compare f with WREG, skip if f > WREG Compare f with WREG, skip if f < WREG Decrement f Decrement f, skip if 0 Decrement f, skip if not 0 Increment f Increment f, skip if 0 Increment f, skip if not 0 Inclusive OR WREG with f Move f Move fs (first word) to fd (second word) Move WREG to f Multiply WREG with f Negate f Rotate left f through Carry Rotate left f (no carry)
64f
CPFSGT
f,a
60 f
CPFSLT
f,a
04 f 2C f
DECF DECFSZ
f,d,a f,d,a
4C f
DCFSNZ
f,d,a
28 f 3C f
INCF INCFSZ
f,d,a f,d,a
48f
INFSNZ
f,d,a
44 f
RLNCF
f,d,a
Mnemonic
RRCF f,d,a
Description
Rotate right f through Carry Rotate right f (no carry)
C
Function
register f 7. .. .. .0 register f 7 . .. .. .0
40 f
RRNCF
f,d,a
SETF
f,a
Set f
0xFF f
Subtract f from WREG WfC dest with Borrow Subtract WREG from f fW dest Subtract WREG from f fWC dest with Borrow Swap nibbbles of f Test f, skip if 0 Exclusive OR WREG with f f<3:0> dest<7:4>, f<7:4> dest<3:0> PC+4 PC, if f=0, else PC+2 PC W .XOR. f dest
/x
extract member;
/q
quiet mode;