Download - INSTRUCTION SET
![Page 1: INSTRUCTION SET](https://reader036.vdocuments.net/reader036/viewer/2022062315/56814bc1550346895db8980f/html5/thumbnails/1.jpg)
INSTRUCTION SETINSTRUCTION SET
![Page 2: INSTRUCTION SET](https://reader036.vdocuments.net/reader036/viewer/2022062315/56814bc1550346895db8980f/html5/thumbnails/2.jpg)
INSTRUCTION 5INSTRUCTION 5
![Page 3: INSTRUCTION SET](https://reader036.vdocuments.net/reader036/viewer/2022062315/56814bc1550346895db8980f/html5/thumbnails/3.jpg)
INSTRUCTION 6INSTRUCTION 6
![Page 4: INSTRUCTION SET](https://reader036.vdocuments.net/reader036/viewer/2022062315/56814bc1550346895db8980f/html5/thumbnails/4.jpg)
INSTRUCTION 7INSTRUCTION 7
![Page 5: INSTRUCTION SET](https://reader036.vdocuments.net/reader036/viewer/2022062315/56814bc1550346895db8980f/html5/thumbnails/5.jpg)
INSTRUCTION 8INSTRUCTION 8
![Page 6: INSTRUCTION SET](https://reader036.vdocuments.net/reader036/viewer/2022062315/56814bc1550346895db8980f/html5/thumbnails/6.jpg)
INSTRUCTION 9INSTRUCTION 9
![Page 7: INSTRUCTION SET](https://reader036.vdocuments.net/reader036/viewer/2022062315/56814bc1550346895db8980f/html5/thumbnails/7.jpg)
INSTRUCTION 10INSTRUCTION 10
![Page 8: INSTRUCTION SET](https://reader036.vdocuments.net/reader036/viewer/2022062315/56814bc1550346895db8980f/html5/thumbnails/8.jpg)
INSTRUCTION 11INSTRUCTION 11
![Page 9: INSTRUCTION SET](https://reader036.vdocuments.net/reader036/viewer/2022062315/56814bc1550346895db8980f/html5/thumbnails/9.jpg)
INSTRUCTION 12INSTRUCTION 12
![Page 10: INSTRUCTION SET](https://reader036.vdocuments.net/reader036/viewer/2022062315/56814bc1550346895db8980f/html5/thumbnails/10.jpg)
INSTRUCTION 13INSTRUCTION 13
![Page 11: INSTRUCTION SET](https://reader036.vdocuments.net/reader036/viewer/2022062315/56814bc1550346895db8980f/html5/thumbnails/11.jpg)
INSTRUCTION 14INSTRUCTION 14
![Page 12: INSTRUCTION SET](https://reader036.vdocuments.net/reader036/viewer/2022062315/56814bc1550346895db8980f/html5/thumbnails/12.jpg)
INSTRUCTION 15INSTRUCTION 15
![Page 13: INSTRUCTION SET](https://reader036.vdocuments.net/reader036/viewer/2022062315/56814bc1550346895db8980f/html5/thumbnails/13.jpg)
INSTRUCTION 16INSTRUCTION 16
![Page 14: INSTRUCTION SET](https://reader036.vdocuments.net/reader036/viewer/2022062315/56814bc1550346895db8980f/html5/thumbnails/14.jpg)
INSTRUCTION 17INSTRUCTION 17
![Page 15: INSTRUCTION SET](https://reader036.vdocuments.net/reader036/viewer/2022062315/56814bc1550346895db8980f/html5/thumbnails/15.jpg)
INSTRUCTION 18INSTRUCTION 18
![Page 16: INSTRUCTION SET](https://reader036.vdocuments.net/reader036/viewer/2022062315/56814bc1550346895db8980f/html5/thumbnails/16.jpg)
INSTRUCTION 19INSTRUCTION 19
![Page 17: INSTRUCTION SET](https://reader036.vdocuments.net/reader036/viewer/2022062315/56814bc1550346895db8980f/html5/thumbnails/17.jpg)
INSTRUCTION 20INSTRUCTION 20
![Page 18: INSTRUCTION SET](https://reader036.vdocuments.net/reader036/viewer/2022062315/56814bc1550346895db8980f/html5/thumbnails/18.jpg)
INSTRUCTION 21INSTRUCTION 21
![Page 19: INSTRUCTION SET](https://reader036.vdocuments.net/reader036/viewer/2022062315/56814bc1550346895db8980f/html5/thumbnails/19.jpg)
INSTRUCTION 22INSTRUCTION 22
![Page 20: INSTRUCTION SET](https://reader036.vdocuments.net/reader036/viewer/2022062315/56814bc1550346895db8980f/html5/thumbnails/20.jpg)
INSTRUCTION 23INSTRUCTION 23
![Page 21: INSTRUCTION SET](https://reader036.vdocuments.net/reader036/viewer/2022062315/56814bc1550346895db8980f/html5/thumbnails/21.jpg)
INSTRUCTION 24INSTRUCTION 24
![Page 22: INSTRUCTION SET](https://reader036.vdocuments.net/reader036/viewer/2022062315/56814bc1550346895db8980f/html5/thumbnails/22.jpg)
INSTRUCTION 25INSTRUCTION 25
![Page 23: INSTRUCTION SET](https://reader036.vdocuments.net/reader036/viewer/2022062315/56814bc1550346895db8980f/html5/thumbnails/23.jpg)
INSTRUCTION 26INSTRUCTION 26
![Page 24: INSTRUCTION SET](https://reader036.vdocuments.net/reader036/viewer/2022062315/56814bc1550346895db8980f/html5/thumbnails/24.jpg)
INSTRUCTION 27INSTRUCTION 27
![Page 25: INSTRUCTION SET](https://reader036.vdocuments.net/reader036/viewer/2022062315/56814bc1550346895db8980f/html5/thumbnails/25.jpg)
INSTRUCTION 28INSTRUCTION 28
![Page 26: INSTRUCTION SET](https://reader036.vdocuments.net/reader036/viewer/2022062315/56814bc1550346895db8980f/html5/thumbnails/26.jpg)
INSTRUCTION 29INSTRUCTION 29
![Page 27: INSTRUCTION SET](https://reader036.vdocuments.net/reader036/viewer/2022062315/56814bc1550346895db8980f/html5/thumbnails/27.jpg)
INSTRUCTION 30INSTRUCTION 30
![Page 28: INSTRUCTION SET](https://reader036.vdocuments.net/reader036/viewer/2022062315/56814bc1550346895db8980f/html5/thumbnails/28.jpg)
INSTRUCTION 31INSTRUCTION 31
![Page 29: INSTRUCTION SET](https://reader036.vdocuments.net/reader036/viewer/2022062315/56814bc1550346895db8980f/html5/thumbnails/29.jpg)
INSTRUCTION 32INSTRUCTION 32
![Page 30: INSTRUCTION SET](https://reader036.vdocuments.net/reader036/viewer/2022062315/56814bc1550346895db8980f/html5/thumbnails/30.jpg)
INSTRUCTIONS 33-35INSTRUCTIONS 33-35
SLEEPSLEEP CLRWDTCLRWDT NOPNOP
![Page 31: INSTRUCTION SET](https://reader036.vdocuments.net/reader036/viewer/2022062315/56814bc1550346895db8980f/html5/thumbnails/31.jpg)
Direct/Indirect AddressingDirect/Indirect Addressing
![Page 32: INSTRUCTION SET](https://reader036.vdocuments.net/reader036/viewer/2022062315/56814bc1550346895db8980f/html5/thumbnails/32.jpg)
Direct AddressingDirect Addressing
Use only 7 bits of instruction to identify a register file Use only 7 bits of instruction to identify a register file address.address.
The other two bits of register address come from RP0 and The other two bits of register address come from RP0 and RP1 bits in the STATUS registerRP1 bits in the STATUS register
Example: Bank switching (Note: case of 4 banks)Example: Bank switching (Note: case of 4 banks) CLRF STATUS ; Clear STATUS register (Bank0)CLRF STATUS ; Clear STATUS register (Bank0) : ;: ; BSF STATUS, RP0 ; Bank1BSF STATUS, RP0 ; Bank1 : ;: ; BCF STATUS, RP0 ; Bank0BCF STATUS, RP0 ; Bank0 : ;: ; MOVLW 0x60 ; Set RP0 and RP1 in STATUS register, otherMOVLW 0x60 ; Set RP0 and RP1 in STATUS register, other XORWF STATUS, F ; bits unchanged (Bank3)XORWF STATUS, F ; bits unchanged (Bank3) : ;: ; BCF STATUS, RP0 ; Bank2BCF STATUS, RP0 ; Bank2 : ;: ; BCF STATUS, RP1 ; Bank0BCF STATUS, RP1 ; Bank0
![Page 33: INSTRUCTION SET](https://reader036.vdocuments.net/reader036/viewer/2022062315/56814bc1550346895db8980f/html5/thumbnails/33.jpg)
Indirect AddressingIndirect Addressing The INDF register is not a physical register. Addressing the The INDF register is not a physical register. Addressing the
INDF register will cause indirect addressing.INDF register will cause indirect addressing. Any instruction using the INDF register actually access the Any instruction using the INDF register actually access the
registerregister pointed to by the File Select Register (FSR).pointed to by the File Select Register (FSR). The effective 9-bit address is obtained by concatenating the The effective 9-bit address is obtained by concatenating the
8-bit8-bit FSR register and the IRP bit in STATUS register.FSR register and the IRP bit in STATUS register. ExampleExample
MOVLW 0x20 ;initialize pointerMOVLW 0x20 ;initialize pointer MOVWF FSR ;to RAMMOVWF FSR ;to RAM NEXT: CLRF INDF ;clear INDF registerNEXT: CLRF INDF ;clear INDF register INCF FSR,F ;inc pointerINCF FSR,F ;inc pointer BTFSS FSR,4 ;all done? (to 0x2F)BTFSS FSR,4 ;all done? (to 0x2F) GOTO NEXT ;no clear nextGOTO NEXT ;no clear next CONTINUE:CONTINUE:
;yes continue;yes continue
![Page 34: INSTRUCTION SET](https://reader036.vdocuments.net/reader036/viewer/2022062315/56814bc1550346895db8980f/html5/thumbnails/34.jpg)
I/O PortsI/O Ports General I/O pins are the simplest of peripherals General I/O pins are the simplest of peripherals
used to monitor and control other devices.used to monitor and control other devices. For most ports, the I/O pin’s direction (input or For most ports, the I/O pin’s direction (input or
output) is controlled by the data direction output) is controlled by the data direction register register TRISx TRISx (x=A,B,C,D,E).(x=A,B,C,D,E).
A ‘1’ in the TRIS bit corresponds to that pin being A ‘1’ in the TRIS bit corresponds to that pin being an input, while a ‘0’ corresponds to that pin an input, while a ‘0’ corresponds to that pin being an outputbeing an output
The The PORTx PORTx register is the latch for the data to register is the latch for the data to be output. Reading PORTx register read the be output. Reading PORTx register read the status of the pins, whereas writing to it will write status of the pins, whereas writing to it will write to the port latch.to the port latch.
![Page 35: INSTRUCTION SET](https://reader036.vdocuments.net/reader036/viewer/2022062315/56814bc1550346895db8980f/html5/thumbnails/35.jpg)
Example: Initializing PORTDExample: Initializing PORTD
bcf STATUS, RP0 ; bank0bcf STATUS, RP0 ; bank0 bcf STATUS, RP1bcf STATUS, RP1 clrf PORTD ; initializing PORTD by clearing output clrf PORTD ; initializing PORTD by clearing output
data latchesdata latches bsf STATUS, RP0 ; select bank1bsf STATUS, RP0 ; select bank1 movlw 0xCF ; value used to initialize data movlw 0xCF ; value used to initialize data
direction (1100 1111)direction (1100 1111) movwf TRISD ; movwf TRISD ;
PORTD<7:6>=inputs, ;PORTD<5:4>=outputs, PORTD<7:6>=inputs, ;PORTD<5:4>=outputs, PORTD<3:0>=inputsPORTD<3:0>=inputs