general form of instruction pic inst.pdf · 2012. 5. 8. · 2. f877 instruction set. 14-bit word....

Post on 11-Mar-2021

2 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

1

PIC16F877 Instruction Set

PIC – INSTRUCTION SET

Dr. Charles J. Kim

Howard University

faculty
Typewritten Text
WWW.MWFTR.COM

2

F877 Instruction Set� 14-Bit Word� Byte-Oriented Instruction

�F: File Register (or RAM)�D: Destination

⌧D=0: Destination � W⌧D=1: Destination � File Register

� Bit-Oriented Instruction�B: Bit Field�F: Register File where the Bit is located

� Literal and Control Operation�K: 8-bit constant

3

General Form of Instruction

4

Instruction List

5

Destination of the result�D=0: Destination � W�D=1: Destination � File Register (Default)

�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

6

Register Addressing Modes�Immediate Addressing

⌧(ex) MOVLW 0x0F�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.

� (ex) SSPCON EQU 0x14STATUS EQU 0x03SSPSTAT EQU 0x94BCF STATUS, 0x05BCF SSPCON, 0x01BSF STATUS, 0x05BCF SSPSTAT, 0x02

7

Direct Addressing

8

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 0x20; pointerMovwf FSR

Next clrf INDF

incf FSRbtfss FSR, 4

goto next

……

9

Direct vs. Indirect Addressing

10

Instruction Sets –description convention

11

addlw

12

addwf

13

andlw

14

andwf

15

Bcf & bsf

16

btfsc

17

Btfss

18

Call

19

CLRF & CLRW

20

COMF & DECF

21

DECFSZ

22

GOTO & INCF

23

INCFSZ

24

IORLW & IORWF

25

MOVLW & MOVF

26

MOVWF & NOP

27

RETFIE & RETLW

28

RETURN

29

RLF & RRF

30

SUBLW & SUBWF

31

SWAPF & XORLW

32

XORWF

top related