PIC18 Series Family Instructions Quick Index

Publisher:dst2015Latest update time:2019-11-13 Source: 51hei Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

PIC instruction

instruction

Instruction description

influence flag

Reference page number

BYTE-ORIENTED FILE REGISTER OPERATIONS

ADDWF

f, d, a

Add W and f and put the result in W or f.

C, DC, Z, OV, N

7

ADDWFC

f, d, a

Add W and C and put the result in W or f.

C, DC, Z, OV, N

10

ANDWF

f, d, a

Perform an AND operation on W and f, and put the result in W or f.

Z,N

14

CLRF

f, a

Clear all values ​​in f to 0.

Z

31

COMF

f, d, a

Complement the value in f and place the result in W or f.

Z,N

33

CPFSEQ

f, a

If the values ​​of f and W are equal, the next instruction is skipped.

none

35

CPFSGT

f, a

If f is greater than W, skip the next instruction.

none

36

CPFSLT

f, a

If f is less than W, skip the next instruction.

none

37

DECF

f, d, a

Decrement the value in f by 1 and place the result in W or f.

C, DC, Z, OV, N

40

DECFSZ

f, d, a

Decrement the value in f by 1. If it is 0, skip the next instruction and put the result in W or f.

none

43

DCFSNZ

f, d, a

Decrement the value in f by 1. If it is not 0, skip the next instruction and put the result in W or f.

none

45

INCF

f, d, a

Add 1 to the value in f and place the result in W or f.

C, DC, Z, OV, N

48

INCFSZ

f, d, a

Add 1 to the value in f. If it is 0, skip the next instruction and put the result in W or f.

none

51

INFSNZ

f, d, a

Add 1 to the value in f. If it is not 0, skip the next instruction and put the result in W or f.

none

53

IORWF

f, d, a

Perform an OR operation on W and f, and put the result into W or f.

Z,N

57

MOVF

f, d, a

Move the value in f to W or f.

Z,N

61

MOVFF

Move the data inside .

none

63

MOVWF

f, a

Move the value in W to f.

none

66

MULWF

f, a

Multiply W and f.

none

68

NEGF

f, a

Take the 2's complement of the value in f.

C, DC, Z, OV, N

70

RLCF

f, d, a

Move the value in f to the left together with C, and put the result in W or f.

C, Z, N

80

RLNCF

f, d, a

Move the value in f to the left and put the result in W or f.

Z,N

82

RRCF

f, d, a

Move the value in f right together with C, and put the result into W or f.

C, Z, N

84

RRNCF

f, d, a

Move the value in f right and put the result in W or f.

Z,N

86

SETF

f, a

Set the value in f to 0xFF.

none

88

SUBFWB

f, d, a

Subtract C and f from the value in W and place the result in W or f.

C, DC, Z, OV, N

90

SUBWF

f, d, a

Subtract f from the value in W and place the result in W or f.

C, DC, Z, OV, N

94

SUBWFB

f, d, a

Subtract W and C from the value in f and place the result in W or f.

C, DC, Z, OV, N

96

SWAPF

f, d, a

Swap the high 4 bits and low 4 bits of the value in f, and place the result in W or f.

none

98

TSTFSZ

f, a

Test whether the value in f is equal to 0. If it is 0, skip the next instruction.

none

105

XORWF

f, d, a

Perform XOR operation on W and f, and put the result into W or f.

Z,N

108

Bit operation instructions (BIT-ORIENTED FILE REGISTER OPERATIONS)

BCF

f, b, a

Set a certain bit in f to 0.

none

17

BSF

f, b, a

Set a certain bit in f to 1.

none

twenty four

BTFSC

f, b, a

Test whether the value of a certain bit in f is equal to 0. If it is 0, skip the next instruction.

none

25

BTFSS

f, b, a

Test whether the value of a certain bit in f is equal to 1. If it is 1, skip the next instruction.

none

26

BTG

f, d, a

Perform NOT operation on a certain bit in f.

none

27

Note:

Ff represents the temporary register.

Fd indicates where the data is stored, d = 0 indicates it is stored in the W accumulator; d = 1 indicates it is stored in the f register.

Fb represents the b-th bit of the temporary register.


Fk represents an 8-bit constant.

Fa indicates which memory location the data is stored in. a = 0 indicates that it is placed in the current memory location; a = 1 indicates that it is placed in the memory location specified in the BSR register.

Fn represents the address of the program memory.









PIC18 Series Family Instructions Quick Index (continued)

instruction

Instruction description

influence flag

Reference page number

Program flow control instructions (CONTROL OPERATIONS)

B.C.

n

If C = 1, jump to address n.

none

16

BN

n

If N = 1, jump to address n.

none

18

BNC

n

If C = 0, jump to address n.

none

19

BNN

n

If N = 0, jump to address n.

none

20

BNOV

n

If OV = 0, jump to address n.

none

twenty one

BNZ

n

If Z = 0, jump to address n.

none

twenty two

BOV

n

If OV = 1, jump to address n.

none

28

BRA

n

Unconditionally jump to address n ( ).

none

twenty three

BZ

n

If Z = 1, jump to address n.

none

29

CALL

n, s

Store the PC value of the next instruction to the top level of the stack and jump to address n ( ).

none

30

CLRWDT


Clear the watchdog timer to 0.

none

32

DAW


Make BCD adjustments to the values ​​in W.

none

38

GOTO

n

Unconditionally jump to address n ( ).

none

47

NOP


Empty command.

none

72

POP


Take out the value at the top of the stack.

none

73

PUSH


Store the PC value of the next instruction to the top level of the stack.

none

74

RCALL

n

Store the PC value of the next instruction to the top level of the stack and jump to address n ( ).

none

75

RESET


Use software to reset the system.

none

76

RETFIE

s

The interrupt subroutine returns to the main program, and the value at the top of the stack is taken out and placed in the PC, and the main program starts execution from the current PC value.

none

77

RETURN

s

Return to the main program from the sub-program, take out the value at the top of the stack and put it into the PC, and the main program starts executing from the current PC value.

none

79

SLEEP


Go to sleep.

none

89

Note:

Ff represents the temporary register.

Fd indicates where the data is stored, d = 0 indicates it is stored in the W accumulator; d = 1 indicates it is stored in the f register.

Fb represents the b-th bit of the temporary register.


Fk represents an 8-bit constant.

Fn represents the address of the program memory.

Fa indicates which memory location the data is stored in. a = 0 indicates that it is placed in the current memory location; a = 1 indicates that it is placed in the memory location specified in the BSR register.








 


PIC18 Series Family Instructions Quick Index (continued)

instruction

Instruction description

influence flag

Reference page number

Immediate constant addressing (LITERAL OPERATIONS)

ADDLW

k

Add the constant k and W.

C, DC, Z, OV, N

4

ANDLW

k

Do an AND operation with the constant k and W.

Z,N

12

IORLW

k

Do an OR operation with the constant k and W.

Z,N

55

LFSR

f,k

Move the constant k (12-bit) to the f-th FSR register (f = 0 ~ 2).

none

59

MOVLB

k

Move the constant k to the BSR register.

none

64

MOVL

k

Move the constant k to W.

none

65

MULLW

k

Multiply the constant k and W.

none

67

RETLW

k

Take out the value of the top layer of the stack and put it into PC, and set the value of W to k ( ), and the main program starts executing from the current PC value.

none

78

SUBLW

k

Subtract the constant k from W.

C, DC, Z, OV, N

92

XORLW

k

Perform XOR operation on constant k and W.

Z,N

106

Program memory read and write instructions (DATA MEMORY <-> PROGRAM MEMORY OPERATIONS)

TBLRD*


Using the contents of the TBLPTRH and TBLPTRL registers as address pointers, read the contents of the program memory into the TABLAT register.

none

99

TBLRD*+


Using the contents of the TBLPTRH and TBLPTRL recorders as address pointers, read the contents of the program memory into the TABLAT register, and then automatically add 1 to the address pointer.

none

99

TBLRD*-


Using the contents of the TBLPTRH and TBLPTRL recorders as address pointers, read the contents of the program memory into the TABLAT register, and then automatically decrement the address pointer by 1.

none

99

TBLRD+*


First add 1 to the TBLPTRH and TBLPTRL recorders, and then use the contents of the TBLPTRH and TBLPTRL recorders as address pointers to read the contents of the program memory into the TABLAT register.

none

99

TBLWT*


Using the contents of the TBLPTRH and TBLPTRL registers as address pointers, write the value in the TABLAT register into the program memory.

none

102

TBLWT*+


Using the contents of the TBLPTRH and TBLPTRL registers as address pointers, write the value in the TABLAT register into the program memory, and then automatically increase the address pointer by 1.

none

102

TBLWT*-


Using the contents of the TBLPTRH and TBLPTRL recorders as the address pointer, write the value in the TABLAT register into the program memory, and then automatically decrement the address pointer by 1.

none

102

TBLWT+*


First add 1 to the TBLPTRH and TBLPTRL recorders, and then use the contents of the TBLPTRH and TBLPTRL recorders as address pointers to write the value in the TABLAT register into the program memory.

none

102

Note:

Ff represents the temporary register.

Fd indicates where the data is stored, d = 0 indicates it is stored in the W accumulator; d = 1 indicates it is stored in the f register.

Fb represents the b-th bit of the temporary register.


Fk represents an 8-bit constant.

Fn represents the address of the program memory.

Fa indicates which memory location the data is stored in. a = 0 indicates that it is placed in the current memory location; a = 1 indicates that it is placed in the memory location specified in the BSR register.








 


Command name: ADDLW

Original meaning: ADD literal to W

Syntax: [label] ADDLW k

Operator:

Operation description: (W) + K -> W

Impact flags: N, OV, C, DC, Z

Instruction description: Add the value in the W accumulator to the k value, and put the operation result back into the W accumulator.

Category: Immediate constant addressing method.

Group: Mathematical operation addition instructions.

Example 1:

ADDLW 0x11; Add the value of 0x11 to the W accumulator, and put the result back into the W accumulator.

Before execution:

W = 0x1F; Assume that the value of W accumulator before execution is 0x1F.
N = OV = C = DC = Z = 0; Assume that the values ​​of the status register before execution are all 0.

After execution:

W = 0x30; After execution, the value of W accumulator is 0x30.
N = OV = C = 0, DC = 1; the half-carry flag is equal to 1, because a carry occurs after the low four bits are added, so the half-carry flag DC is equal to 1 and the status of the other flags remains unchanged.


Example 2:

ADDLW 0x11; Add the value of 0x11 to the W accumulator, and put the result back into the W accumulator.

Before execution:

W = 0x7F; Assume that the value of W accumulator before execution is 0x7F.

N = OV = C = DC = Z = 0; Assume that the values ​​of the status register before execution are all 0.

After execution:

W = 0x90; after execution, the value of W accumulator is 0x90.

N = OV = DC = 1, Z = C = 0; the half-carry flag DC is equal to 1, because a carry occurs after the low four bits are added; the overflow flag OV is equal to 1, because after the two numbers are added, the third A carry situation occurs in 7 bits; the negative flag N is equal to 1, because the result after adding the two numbers is greater than 127, and because 2's complement is used for the operation, the result greater than 127 is considered a negative sign.

Example three:

[1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11]
Reference address:PIC18 Series Family Instructions Quick Index

Previous article:Ultrasonic PIC microcontroller C program
Next article:Single chip microcomputer EC1 digital rotary encoder simulation program

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号