Lec10 Pic Inst
Lec10 Pic Inst
Lec10 Pic Inst
source: www.mwftr.com
Instruction List
addwf PORTD ; Add content of PORTD to content of the W and store the result back into PORTD addwf PORTD, 0 ; Add content of PORTD to content of the W and store the result into W
Direct Addressing
Uses 7 bits of 14 bit instruction to identify a register file address 8th and 9th bit comes from RP0 and RP1 bits of STATUS register. Initial condition for RP0 and RP1: RP1=RP0=0 (ex) SSPCON EQU 0x14 STATUS EQU 0x03 SSPSTAT EQU 0x94 BCF STATUS, 0x05 BCF SSPCON, 0x01 BSF STATUS, 0x05 BCF SSPSTAT, 0x02
Indirect Addressing
INDF register
Any instruction using the INDF actually accesses the register pointed to by the File Select Register (FSR).
A 9-bit EA is obtained by concatenating the 8-bit FSR register and the IRP bit(STATUS<7>) Example: Erase the RAM section of 0x20-0x2F
Movlw Movwf Next clrf incf btfss goto 0x20; pointer FSR INDF FSR FSR, 4 next
10
addlw
11
addwf
12
andlw
13
andwf
14
15
btfsc
16
Btfss
17
Call
18
19
20
DECFSZ
21
22
INCFSZ
23
24
25
26
27
RETURN
28
29
30
31
XORWF
32
33
34
35
Buzzer
1: Buzzer On 0: Buzzer Off
Sample Code
40