PIC18 2003 Microchip Techology Icorporated. All Rights Reserved. PICmicro PIC18 51
PIC18 Istructios PIC16, PIC17 16 16 8x8 2003 Microchip Techology Icorporated. All Rights Reserved. PICmicro PIC18 52
PIC18 Istructios ( ) 71 ; 4 17 18 1,2( 3) MOVFF 2003 Microchip Techology Icorporated. All Rights Reserved. PICmicro PIC18 53
PIC18 Istructio Byte-Orieted Operatios ADDWF ADDWFC ANDWF CLRF f [,a] COMF CPFSEQ f [,a] CPFSGT f [,a] CPFSLT f [,a] DECF DECFSZ DCFSNZ INCF INCFSZ INFSNZ IORWF MOVF MOVFF fs, fd MOVWF f [,a] 16-bit Istructio for Byte Orieted Operatios OP CODE d = Destiatio Bit W' for WREG (0) F for f (1 - Default) a = Access Bit ACCESS (0) BANKED (1 - Default) Example: ADDWF ADDWF d Cout a f f f f f f f f f = 8-bit Register Address MOVFF fs, fd MOVFF Source, Dest 2003 Microchip Techology Icorporated. All Rights Reserved. PICmicro PIC18 54
PIC18 Istructios ( ) Byte-Orieted Operatios MULWF f [,a] NEGF f [,a] RLCF RLNCF RRCF RRNCF SETF f [,a] SUBFWB SUBWF SUBWFB SWAPF TSTFSZ f [,a] XORWF 16-bit Istructio for Byte Orieted Operatios OP CODE d = Destiatio Bit W for WREG (0) F for f (1 - Default) a = Access Bit ACCESS (0) BANKED (1 - Default) Example: SUBWF SUBWF d Value, W a f f f f f f f f f = 8-bit Register Address 2003 Microchip Techology Icorporated. All Rights Reserved. PICmicro PIC18 55
PIC18 Istructios (4 ) : Cout32++ movlw addwf clrf addwfc addwfc addwfc 01h Cout32, F WREG Cout32+1, F Cout32+2, F Cout32+3, F ; Ic LSB by 1 ; Pass the carry ; to LOW MSB ; to HIGH LSB ; to HIGH MSB 2003 Microchip Techology Icorporated. All Rights Reserved. PICmicro PIC18 56
PIC18 Istructios Bit-Orieted Operatios 16-bit Istructio for Bit Orieted Operatios BCF BSF BTG BTFSC BTFSS f, b [,a] f, b [,a] f, b [,a] f, b [,a] f, b [,a] OP CODE b b = 3-Bit Address (Bit Number) b b a f f f f f f f f a = Access Bit ACCESS (0) BANKED (1 - Default) f = 8-bit Register Address Example: BTFSC BTFSC f, b [,a] STATUS, C 2003 Microchip Techology Icorporated. All Rights Reserved. PICmicro PIC18 57
Cotrol Operatios BC BN BNC BNN BNOV BNZ BOV BRA BZ CALL GOTO RCALL RETFIE RETURN [,s] [s] [s] PIC18 Istructios 16-bit Istructio for CALL ad GOTO OP CODE s = 20-bit Immediate Value 16-bit Istructio for RCALL ad BRA OP CODE = 11-bit Immediate Value OP CODE s = 1-bit fast Save/Restore FAST (1), (Default - 0) 2003 Microchip Techology Icorporated. All Rights Reserved. PICmicro PIC18 58
Cotrol Operatios BC BN BNC BNN BNOV BNZ BOV BRA BZ CALL GOTO RCALL RETFIE RETURN [,s] [s] [s] PIC18 Istructios ( ) () -128 +127 CALLGOTO21 2MB RCALL-1024 1023 2003 Microchip Techology Icorporated. All Rights Reserved. PICmicro PIC18 59
PIC18 Istructios ( ) Cotrol Operatios CLRWDT DAW NOP POP PUSH RESET SLEEP 16-bit Istructio for CLRWDT OP CODE 16-bit Istructio for DAW OP CODE PUSHPOP DAWWREG 2003 Microchip Techology Icorporated. All Rights Reserved. PICmicro PIC18 60
PIC18 Istructios #1 call MyFuc,, FAST MyFuc: retur Callig Subroutie FAST org bra HighISR: retfie Hadlig Iterrupt 00008h HighISR FAST 2003 Microchip Techology Icorporated. All Rights Reserved. PICmicro PIC18 61
PIC18 Istructios #2 BRB6 btfsc PORTB, RB6 ; Is RB6 low? bra $-2 ; No. Wait ; Yes. 2003 Microchip Techology Icorporated. All Rights Reserved. PICmicro PIC18 62
Literal Operatios ADDLW ANDLW IORLW LFSR MOVLB MOVLW MULLW RETLW SUBLW XORLW f, PIC18 Istructios 16-bit Istructio for LFSR OP CODE f f f = 2-bit FSR Selector FSR0, FSR1 or FSR2 = 8-bit Immediate Value OP CODE = 8-bit Immediate Value Example: MOVLW LFSR f, MOVLW 5Ah LFSR FSR0, 400h 16-bit Istructio for Other Literal Operatios 2003 Microchip Techology Icorporated. All Rights Reserved. PICmicro PIC18 63
PIC18 Istructios movlw movwf Immediate Operatio 55h PORTB Idirect Operatio lfsr FSR0, 400h movwf INDF0 ; *FSR0 movwf POSTINC0 ; *FSR0++ movwf POSTDEC0 ; *FSR0-- movwf PREINC0 ; *++FSR0 movwf PLUSW0 ; FSR0[WREG] 2003 Microchip Techology Icorporated. All Rights Reserved. PICmicro PIC18 64
PIC18 Istructios Cotrol Operatios TBLRD* TBLRD*+ TBLRD*- TBLRD+* TBLWT* TBLWT*+ TBLWT*- TBLWT+* Example: TBLRD* TBLRD*+ 16-bit Istructio for TBLRD*/TBLWT* OP CODE TBLRDTBLWTTABLAT / 2003 Microchip Techology Icorporated. All Rights Reserved. PICmicro PIC18 65
PIC18 Istructios : movlw movwf movlw movwf movlw movwf tblrd*+ upper(loouptable LooUpTable) TBLPTRU high(loouptable LooupTable) TBLPTRH low(loouptable LooupTable) TBLPTRL ; Load loo-up ; table ; address ; Read it. 2003 Microchip Techology Icorporated. All Rights Reserved. PICmicro PIC18 66