PASM Directives Function ------------------------------------------------------------------------------------------------------------------------------- label = value Assign value to label label EQU value Assign value to label DEVICE x,x,x,x Define device (see PIC.EQU) ID value16 Assign value16 to device id ID CHECKSUM Assign computed checksum to device id RESET addr9 Assemble into last location JMP addr9 ORG address Set origin to address DS bytes Define space of bytes INCLUDE 'file' Include file into source PASM Instructions (1 word) Function Manufacturer's Equivalent ------------------------------------------------------------------------------------------------------------------------------- (Operations affecting W) CLR W Clear W to 0 CLRW MOV W,#lit Move literal byte to W MOVLW lit MOV W,fr Move fr to W MOVF fr,0 MOV W,/fr Move not of fr to W COMF fr,0 MOV W,fr-w Move fr-W to W SUBWF fr,0 MOV W,++fr Move fr+1 to W INCF fr,0 MOV W,--fr Move fr-1 to W DECF fr,0 MOV W,>>fr Move right shift of fr to W RRF fr,0 MOV W,<fr Move nibble swap of fr to W SWAPF fr,0 ADD W,fr Add fr to W ADDWF fr,0 AND W,#lit AND W with literal byte ANDLW lit AND W,fr AND W with fr ANDWF fr,0 OR W,#lit OR W with literal byte IORLW lit OR W,fr OR W with fr IORWF fr,0 XOR W,#lit Exclusive OR W with literal byte XORLW lit XOR W,fr Exclusive OR W with fr XORWF fr,0 NOT W Not W XORLW 0ffh TEST W Set Z according to W IORLW 0 (Operations affecting fr's) CLR fr Clear fr to 0 CLRF fr MOV fr,W Move W to fr MOVWF fr TEST fr Copy fr to fr and set Z MOVF fr,1 NOT fr Not fr COMF fr,1 SUB fr,W Subtract W from fr SUBWF fr,1 INC fr Increment fr INCF fr,1 DEC fr Decrement fr DECF fr,1 RR fr Rotate right fr RRF fr,1 RL fr Rotate left fr RLF fr,1 SWAP fr Swap nibbles in fr SWAPF fr,1 ADD fr,W Add W to fr ADDWF fr,1 AND fr,W AND fr with W ANDWF fr,1 OR fr,W OR fr with W IORWF fr,1 XOR fr,W Exclusive OR fr with W XORWF fr,1 (Operations affecting bits) CLRB bit Clear bit BCF fr,b SETB bit Set bit BSF fr,b CLC Clear carry BCF 3,0 STC Set carry BSF 3,0 CLZ Clear zero BCF 3,2 STZ Set zero BSF 3,2 (Control operations) MOV !fr,W Move W to I/O control fr (5,6, or 7) TRIS fr MOV OPTION,W Move W to OPTION register OPTION CLR WDT Clear watchdog timer CLRWDT SLEEP Enter sleep mode SLEEP NOP No operation NOP (Conditional branches) MOVSZ W,++fr Move fr+1 to W and skip next instr. if 0 INCFSZ fr,0 MOVSZ W,--fr Move fr-1 to W and skip next instr. if 0 DECFSZ fr,0 INCSZ fr Increment fr and skip next instruction if 0 INCFSZ fr,1 DECSZ fr Decrement fr and skip next instruction if 0 DECFSZ fr,1 SB bit Skip next instruction if bit BTFSS fr,b SNB bit Skip next instruction if not bit BTFSC fr,b SC Skip if carry BTFSS 3,0 SNC Skip if not carry BTFSC 3,0 SZ Skip if zero BTFSS 3,2 SNZ Skip if not zero BTFSC 3,2 (Unconditional branches) JMP addr9 Jump to 9-bit address GOTO addr9 JMP PC+W Jump to 8-bit address PC+W ADDWF 2,1 JMP W Jump to 8-bit address W MOVWF 2,1 CALL addr8 Call 8-bit address CALL addr8 RET Return from call and clear W to 0 RETLW 0 SKIP Skip always BTFSS 4,7 PASM Macros Words Function Manufacturer's Equivalents ------------------------------------------------------------------------------------------------------------------------------- (Operations affecting fr's) NEG fr 2 Negate fr COMF fr,1, INCF fr,1 ADDB fr,bit 2 Add bit to fr BTFSC fr,b, INCF fr,1 SUBB fr,bit 2 Subtract bit from fr BTFSS fr,b, DECF fr,1 (Operations affecting fr's and W) MOV fr,#lit 2 Move literal byte to fr via W MOVLW lit, MOVWF fr MOV fr1,fr2 2 Move fr2 to fr1 via W MOVF fr2,0, MOVWF fr1 ADD fr,#lit 2 Add literal byte to fr via W MOVLW lit, ADDWF fr,1 ADD fr1,fr2 2 Add fr2 to fr1 via W MOVF fr2,0, ADDWF fr1,1 SUB fr,#lit 2 Subtract literal byte from fr via W MOVLW lit, SUBWF fr,1 SUB fr1,fr2 2 Subtract fr2 from fr1 via W MOVF fr2,0, SUBWF fr1,1 AND fr,#lit 2 AND literal byte to fr via W MOVLW lit, ANDWF fr,1 AND fr1,fr2 2 AND fr2 to fr1 via W MOVF fr2,0, ANDWF fr1,1 OR fr,#lit 2 OR literal byte to fr via W MOVLW lit, IORWF fr,1 OR fr1,fr2 2 OR fr2 to fr1 via W MOVF fr2,0, IORWF fr1,1 XOR fr,#lit 2 Exclusive OR literal byte to fr via W MOVLW lit, XORWF fr,1 XOR fr1,fr2 2 Exclusive OR fr2 to fr1 via W MOVF fr2,0, XORWF fr1,1 (Operations affecting bits) MOVB bit1,bit2 4 Move bit2 to bit1 BTFSS fr2,b2, BCF fr1,b1, BTFSC fr2,b2, BSF fr1,b1 MOVB bit1,/bit2 4 Move not of bit2 to bit1 BTFSC fr2,b2, BCF fr1,b1, BTFSS fr2,b2, BSF fr1,b1 LSET addr 0-2 Set page preselect bits to addr 0-2x: BSF 3,bit / BCF 3,bit (Control operations affecting W) MOV !fr,#lit 2 Move literal byte to I/O control fr via W MOVLW lit, TRIS fr MOV !fr1,fr2 2 Move fr2 to I/O control fr1 via W MOVF fr2,0, TRIS fr1 MOV OPTION,#lit 2 Move literal byte to OPTION register via W MOVLW lit, OPTION MOV OPTION,fr 2 Move fr to OPTION register via W MOVF fr,0, OPTION (Conditional branches) IJNZ fr,addr9 2 Increment fr and jump if not 0 INCFSZ fr, GOTO addr9 DJNZ fr,addr9 2 Decrement fr and jump if not 0 DECFSZ fr, GOTO addr9 JB bit,addr9 2 Jump if bit BTFSC bit, GOTO addr9 JNB bit,addr9 2 Jump if not bit BTFSS bit, GOTO addr9 JC addr9 2 Jump if carry BTFSC 3,0, GOTO addr9 JNC addr9 2 Jump if not carry BTFSS 3,0, GOTO addr9 JZ addr9 2 Jump if zero BTFSC 3.2, GOTO addr9 JNZ addr9 2 Jump if not zero BTFSS 3.2, GOTO addr9 CJA fr,#lit,addr9 4 Compare fr to literal and jump if above MOVLW (/lit), ADDWF fr,0, BTFSC 3,0, GOTO addr9 CJA fr1,fr2,addr9 4 Compare fr1 to fr2 and jump if above MOVF fr1,0, SUBWF fr2,0, BTFSS 3,0, GOTO addr9 CJAE fr,#lit,addr9 4 Compare fr to literal and jump if above or equalMOVLW lit, SUBWF fr,0, BTFSC 3,0, GOTO addr9 CJAE fr1,fr2,addr9 4 Compare fr1 to fr2 and jump if above or equal MOVF fr2,0, SUBWF fr1,0, BTFSC 3,0, GOTO addr9 CJB fr,#lit,addr9 4 Compare fr to literal and jump if below MOVLW lit, SUBWF fr,0, BTFSS 3,0, GOTO addr9 CJB fr1,fr2,addr9 4 Compare fr1 to fr2 and jump if below MOVF fr2,0, SUBWF fr1,0, BTFSS 3,0, GOTO addr9 CJBE fr,#lit,addr9 4 Compare fr to literal and jump if below or equalMOVLW (/lit), ADDWF fr,0, BTFSS 3,0, GOTO addr9 CJBE fr1,fr2,addr9 4 Compare fr1 to fr2 and jump if below or equal MOVF fr1,0, SUBWF fr2,0, BTFSC 3,0, GOTO addr9 CJE fr,#lit,addr9 4 Compare fr to literal and jump if equal MOVLW lit, SUBWF fr,0, BTFSC 3,2, GOTO addr9 CJE fr1,fr2,addr9 4 Compare fr1 to fr2 and jump if equal MOVF fr2,0, SUBWF fr1,0, BTFSC 3,2, GOTO addr9 CJNE fr,#lit,addr9 4 Compare fr to literal and jump if not equal MOVLW lit, SUBWF fr,0, BTFSS 3,2, GOTO addr9 CJNE fr1,fr2,addr9 4 Compare fr1 to fr2 and jump if not equal MOVF fr2,0, SUBwf fr1,0, BTFSS 3,2, GOTO addr9 CSA fr,#lit 3 Compare fr to literal and skip if above MOVLW (/lit), ADDWF fr,0, BTFSS 3,0 CSA fr1,fr2 3 Compare fr1 to fr2 and skip if above MOVF fr1,0, SUBWF fr2,0, BTFSC 3,0 CSAE fr,#lit 3 Compare fr to literal and skip if above or equalMOVLW lit, SUBWF fr,0, BTFSS 3,0 CSAE fr1,fr2 3 Compare fr1 to fr2 and skip if above or equal MOVF fr2,0, SUBWF fr1,0, BTFSS 3,0 CSB fr,#lit 3 Compare fr to literal and skip if below MOVLW lit, SUBWF fr,0, BTFSC 3,0 CSB fr1,fr2 3 Compare fr1 to fr2 and skip if below MOVF fr2,0, SUBWF fr1,0, BTFSC 3,0 CSBE fr,#lit 3 Compare fr to literal and skip if below or equalMOVLW (/lit), ADDWF fr,0, BTFSC 3,0 CSBE fr1,fr2 3 Compare fr1 to fr2 and skip if below or equal MOVF fr1,0, SUBWF fr2,0, BTFSS 3,0 CSE fr,#lit 3 Compare fr to literal and skip if equal MOVLW lit, SUBWF fr,0, BTFSS 3,2 CSE fr1,fr2 3 Compare fr1 to fr2 and skip if equal MOVF fr2,0, SUBWF fr1,0, BTFSS 3,2 CSNE fr,#lit 3 Compare fr to literal and skip if not equal MOVLW lit, SUBWF fr,0, BTFSC 3,2 CSNE fr1,fr2 3 Compare fr1 to fr2 and skip if not equal MOVF fr2,0, SUBwf fr1,0, BTFSC 3,2 (Unconditional branches) LJMP addr 1-3 LSET followed by JMP LCALL addr 1-3 LSET followed by CALL RETW 'String',0 ? List of RET's which move literal bytes to W RETLW lit1, RETLW lit2, RETLW lit3, etc. PASM Manufacturer's list ------------------------------------------------------------------------------------------------------------------------------- NOP MOVWF fr CLRW CLRF fr SUBWF * DECF * IORWF * ANDWF * XORWF * ADDWF * MOVF * COMF * INCF * DECFSZ * RRF * RLF * SWAPF * INCFSZ * BCF ** BSF ** BTFSC ** BTFSS ** OPTION SLEEP CLRWDT TRIS fr*** RETLW lit RETLW lit = 0 CALL addr8 GOTO addr9 MOVLW lit IORLW lit ANDLW lit XORLW lit * options: instr fr,d instr fr = fr,1 instr fr,W = fr,0 ** options: instr fr,bn instr bit *** options: fr=5,6, or 7