Professional Documents
Culture Documents
This Quick Reference Guide gives all the instructions, directives and command line options for the Microchip MPASM Assembler.
Syntax
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
Syntax
B00111001 AC C
Define Block of Constants cblock [<expr>] Set configuration bits Pack Strings in 14-bit Memory _ _config <expr> OR _ _config <addr>, <expr> [<label>] da <expr> [, <expr2>, ..., <exprn>]
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>,...,]
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>]
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.
Specify Memory Fill Value fill <expr>, <count> Set ID locations Specify max RAM adr Reserve Memory _ _idlocs <expr> _ _maxram <expr> res <mem_units>
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
MACROS
ENDM EXITM EXPAND LOCAL MACRO NOEXPAND End a Macro Definition Exit from a Macro Expand Macro Listing Declare Local Macro Variable Declare Macro Definition endm exitm expand local <label> [,<label>]
Description
Bit address within an 8 bit file register Store result in W (f0A). Store result in file register f. Default is d = 1.
CONDITIONAL ASSEMBLY
ELSE ENDIF ENDW IF IFDEF IFNDEF WHILE Begin Alternative Assembly to IF else
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.
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> EXTERN GLOBAL IDATA PAGESEL UDATA UDATA_ACS UDATA_OVR UDATA_SHR
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
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
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
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
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
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 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
006f 3Akk
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 Rotate right f Subtract W from f Swap halves f Exclusive OR W and 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 7......0
LCALL
Long Call
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-1d f - 1 d, skip if 0 f+1d f + 1 d, skip if 0 W .OR. f d fd Wf SETC SETDC SETZ SKPC SKPDC SKPNC SKPNDC SKPNZ
register f 7......0 register f 7......0
LGOTO
Long GOTO
Z Z Z Z Z
MOVFW NEGF
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
0Cff
RRF
f,d
Rotate right f
C
Subtract Carry from File Subtract Digit Carry from File Test File
SUBDCF TSTF
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
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
RLNCF f,d
Description
Rotate left (no carry)
Function
register f 7......0 register f 7......0 register f 7......0
Mnemonic
MOVFP f,p k k p,f f t,i,f
Description
Move f to p Move literal to BSR Move literal to RAM page select Move p to f Move W to F Read data from table latch into file f, then update table latch with 16-bit contents of memory location addressed by table pointer Write data from file f to table latch and then write 16-bit table latch to program memory location addressed by table pointer Read data from table latch into file f (table latch unchanged) Write data from file f into table latch 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
Function
TOS PC (PCLATH unchanged) skip if f = 0
b8kk MOVLB bakx MOVLP 4pff 01ff a8ff MOVPF MOVWF TABLRD
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
Function
0 WDT, 0 WDT prescaler, 1 PD, 1 TO Stop oscillator, power down, 0 WDT, 0 WDT Prescaler 1 PD, 1 TO
acff
TABLWT
t,i,f
a0ff
TLRD
t,f
a4ff
TLWT
t,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
Function
0 f(b) 1 f(b) skip if f(b) = 0 skip if f(b) = 1 .NOT. f(b) f(b)
Description
9bff 3bff
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
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
LITERALS
8-bit literal value 4-bit literal value bits 8-11 of 12-bit literal value bits 0-7 of 12-bit literal value
b5kk ANDLW 0aff 28ff 12ff 2eff 06ff 14ff ANDWF CLRF COMF DAW DECF INCF
ekkk CALL
f f f f,d f,d k
PC+1 TOS,k PC(12:0), kk k(12:8) PCLATH(4:0), kb PC(15:13) PCLATH(7:5) kc f-W, skip if f = W kd 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) nn nd ml mm
OFFSETS, ADDRESSES
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
ckkk GOTO
1eff 24ff
INCFSZ INFSNZ
f,d f,d k
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
b0kk MOVLW bckk MULLW 34ff 2cff 1aff MULWF NEGW RLCF
Increment f, skip if not zero (f+1) d, skip if not 0 Long Call (within 64k) Return from interrupt, enable interrupt
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*nnPC, else PC+2PC if N=1, PC+2+2*nnPC, else PC+2PC
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
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
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
RRNCF
f,d,a
SETF
f,a
Set f
0xFF f
Subtract f from WREG W - f - C dest with Borrow Subtract WREG from f f - W dest Subtract WREG from f f - W - C 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
Mnemonic
ADDWF f,d,a ADDWFC f,d,a ANDWF CLRF COMF CPFSEQ CPFSGT CPFSLT DECF DECFSZ f,d,a f,a f,d,a f,a f,a f,a f,d,a f,d,a
Description
ADD WREG to f ADD WREG and Carry bit to f AND WREG with f Clear f Complement f
Function
W+f dest W+f+C dest
Unconditional relative PC+2+2*ndPC 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 same as j`io reset
Compare f with WREG, fW, if f=W, PC+4 PC skip if f=WREG else PC+2 PC Compare f with WREG, fW, if f > W, PC+4 PC skip if f > WREG else PC+2 PC Compare f with WREG, fW, if f < W, PC+4 PC skip if f < WREG else PC+2 PC 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) 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
mm:ml
04f 2Cf
nd
4Cf
DCFSNZ
f,d,a
0010
RETFIE
TOS PC, 1 GIE/GIEH or PEIE/GIEL, if s=1, WS W, STATUSS STATUS, BSRS BSR, PCLATU/PCLATH are unchanged
28f 3Cf
INCF INCFSZ
f,d,a f,d,a
48f
INFSNZ
f,d,a
0Ckk 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
44f
RLNCF
f,d,a
2
Space ! " # $ % & ' ( ) * + , . /
3
0 1 2 3 4 5 6 7 8 9 : ; < = > ?
4
@ A B C D E F G H I J K L M N O
5
P Q R S T U V W X Y Z [ \ ] ^ _
6
` a b c d e f g h i j k l m n o
7
p q r s t u v w x y z { | } ~ DEL
3 4 5 6 7 8 9 A B C D E F
creates a new LIBRARY with the listed MEMBER(s) prints a table showing the names of the members in the LIBRARY deletes MEMBER(s) from the LIBRARY; if no MEMBER is specified the LIBRARY is not altered if MEMBER(s) exist in the LIBRARY, then they are replaced, otherwise MEMBER is appended to the end of the LIBRARY if MEMBER(s) exist in the LIBRARY, then they are extracted. If no MEMBER is specified, all members will be extracted no output is displayed
/x
extract member;
/q
quiet mode;
To display the names of the object modules contained in a library file names dsp.lib, the following command line would be appropriate:
mplib /t dsp.lib