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

N = Z = C = 0; Assume that the status registers are all 0.

After execution:

REG = 0000 0000; the value of the REG register is 00000000.

W = 0000 0000; the value of W register is 00000000.

Z = C = 1; Since the result after shifting to the left is 0, the zero flag Z is 1; the carry flag C is 1.


Command name: RLNCF

Original meaning: Rotate Left f (no Carry)

Syntax: [label] RLNCF f, d

Operator:

Operation description: (f < n >) -> dest ,

     (f < 7 >) -> 7,

Impact flags: N, Z

Instruction description: Rotate the value in the REG temporary memory to the left. If d = 0, the result after the operation is placed in the W accumulator; if d = 1, the result after the operation is placed in the f temporary register. If the temporary register storing the operation result is stored in the W accumulator, We can also write it as W (table W accumulator); if the temporary register storing the operation result is stored in the temporary register, we can also write it as F (table temporary register).

Category: Logical operation instructions.

Group: Logic instructions.

Example 1:

RLNCF REG, 0; Rotate the value of the REG register to the left and store the result back into the W register.

Before execution:

REG = 1110 0110; the value of the REG register is 11100110.

N = Z = 0; Assume that the status registers are all 0.

After execution:

REG = 1110 0110; the value of the REG register is 11100110.

W = 1100 1100; the value of W register is 11001100.

N = 1; Since moving to the left means more negative numbers, the negative flag N is 1.


Example 2:

RLNCF REG, F; Rotate the value of the REG register to the left and store the result back into the REG register.

Before execution:

REG = 1000 0000; the value of the REG register is 10000000.

W = 0000 0000; the value of W register is 00000000.

N = Z = 0; Assume that the status registers are all 0.

After execution:

REG = 0000 0000; the value of the REG register is 00000000.

W = 0000 0000; the value of W register is 00000000.

Z = 1; Since the result after shifting to the left is 0, the zero flag Z is 1.


Command name: RRCF

Original meaning: Rotate Right f through Carry

Syntax: [label] RRCF f, d

Operator:

Operation description: (f < n >) -> dest ,

     (f < 7 >) -> 7,

     ( C ) -> dest <0 >

Impact flags: C, N, Z

Instruction description: Rotate the value in the REG temporary memory to the right together with the carry flag C. If d = 0, the result after the operation is placed in the W accumulator; if d = 1, the result after the operation is placed in the f temporary register. If the temporary register storing the operation result is stored in the W accumulator, We can also write it as W (table W accumulator); if the temporary register storing the operation result is stored in the temporary register, we can also write it as F (table temporary register).

Category: Logical operation instructions.

Group: Logic instructions.

Example 1:

RRCF REG, 0; Rotate the value of the REG register to the right together with the carry flag C, and store the result back into the W register.

Before execution:

REG = 1110 0110; the value of the REG register is 11100110.

N = Z = 0; Assume that the negative flag N and the zero flag Z in the status register are both 0.

C = 1; Assume that the carry flag C is 1.

After execution:

REG = 1110 0110; the value of the REG register is 11100110.

W = 1111 0011; the value of W register is 11110011.

N = Z = C = 0; the negative flag N, zero flag Z and carry flag C in the status register all result in 0.

Example 2:

CLRC; Clear the carry flag C to 0.

RRCF REG, F; Rotate the value of the REG register to the left together with the carry flag C, and store the result back into the REG register.

Before execution:

REG = 0000 0001; the value of the REG register is 00000001.

W = 0000 0000; the value of W register is 00000000.

N = Z = C = 0; the negative flag N, zero flag Z and carry flag C in the status register are all 0.

After execution:

REG = 0000 0000; the value of the REG register is 00000000.

W = 0000 0000; the value of W register is 00000000.

Z = C = 1; Since the result after shifting to the left is 0, the zero flag Z is 1; the carry flag C is 1.

N = 0; the negative flag N is 0.


Command name: RRNCF

Original meaning: Rotate Right f (no Carry)

Syntax: [label] RRNCF f, d

Operator:

Operation description: (f < n >) -> dest ,

     (f < 7 >) -> 7,

Impact flags: N, Z

Instruction description: Rotate the value in the REG temporary memory to the right. If d = 0, the result after the operation is placed in the W accumulator; if d = 1, the result after the operation is placed in the f temporary register. If the temporary register storing the operation result is stored in the W accumulator, We can also write it as W (table W accumulator); if the temporary register storing the operation result is stored in the temporary register, we can also write it as F (table temporary register).

Category: Logical operation instructions.

Group: Logic instructions.

Example 1:

RRNCF REG, 0; Rotate the value of the REG register to the right and store the result back into the W register.

Before execution:

REG = 1110 0110; the value of the REG register is 11100110.

N = Z = 0; Assume that the status registers are all 0.

After execution:

REG = 1110 0110; the value of the REG register is 11100110.

W = 0111 0011; the value of W register is 11001100.

N = Z = 0; both the negative flag N and the zero flag are 0.


Example 2:

RRNCF REG, F; Rotate the value of the REG register to the right and store the result back into the REG register.

Before execution:

REG = 0000 0001; the value of the REG register is 00000001.

W = 0000 0000; the value of W register is 00000000.

N = Z = 0; Assume that the status registers are all 0.

After execution:

REG = 0000 0001; the value of the REG register is 00000001.

W = 0000 0000; the value of W register is 00000000.

Z = 1; Since the result after shifting to the right is 0, the zero flag Z is 1.

N = 0; the negative flag N is 0.


Command name: SETF

Original meaning: Set f

Syntax: [label] SETF f

Operator:

Operation description: 0xFF -> f

Impact flags: None

Instruction description: Set all values ​​in the REG temporary memory to 1.

Category: Data transfer instructions.

Group: Bit setting instructions.

Example 1:

SETF REG; Set all values ​​in the REG register to 1.

Before execution:

REG = 1110 0110; the value of the REG register is 11100110.

After execution:

REG = 1111 1111; the value of the REG register is 11111111.


Command name: SLEEP

Original meaning: Enter SLEEP Mode

Syntax: [label] SLEEP

Operator:

Operation description: 0x00 -> WDT,

0 -> WDT post divider,

,

Impact flags:

Instruction description: CPU enters sleep state.

Category: Program flow control instructions.

Group: Program flow instructions.

Example 1:

SLEEP; Set the CPU to enter sleep state.

Before execution:

     ; The value of AND is unknown.

After execution:

     ; The value of the temporary register is 1.

     ; The value of the temporary register is 0.


Command name: SUBFWB

Original meaning: Subtract f From W with Borrow

Syntax: [label] SUBFWB f, d, a

Operator:

Operation description: (W) – (f) – ( ​​) -> dest

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

Instruction description: Subtract the f register and carry flag C from the value of the W accumulator. If d = 0, the result of the operation is placed in the W accumulator; if d = 1, the result of the operation is placed in f. In the temporary register, if the temporary register that stores the operation result is stored in the W accumulator, we can also write it as W (meaning W accumulator); if the temporary register that stores the operation result is stored in the temporary register, we can also It can be written as F (table register). If a = 0, the result of the operation is placed in the current RAM address; if a = 1, the result of the operation is placed in the RAM address specified by the BSR register.

Category: Data transfer instructions.

Group: Math subtraction instructions.

Example 1:

SUBFWB REG, F, 0; Subtract the REG register and carry flag C from the value of the W accumulator, and put the result of the operation into the REG register.

Before execution:

REG = 3; the value of the REG register is 3.

W = 2; the value of W accumulator is 2.

C = 1; the value of the carry flag C is 1.

After execution:

REG = 0xFF; the value of the REG register is 0xFF.

W = 2; the value of W accumulator is 2.

C = 0; the value of the carry flag C is 0.

Z = 0; the value of zero flag Z is 0.

N = 1; the value of negative flag N is 1.

²The result of the operation is negative.

Example 2:

SUBFWB REG, W, 0; subtract the REG register and carry flag C from the value of the W accumulator, and put the result of the operation into the W accumulator.

Before execution:

REG = 2; the value of the REG register is 2.

W = 5; the value of W accumulator is 5.

C = 1; the value of the carry flag C is 1.

After execution:

REG = 2; the value of the REG register is 2.

W = 3; the value of W accumulator is 3.

C = 1; the value of the carry flag C is 1.

Z = 0; the value of zero flag Z is 0.

N = 0; the value of negative flag N is 0.

²The result of the operation is positive.

Example three:

SUBFWB REG, F, 0; Subtract the REG register and carry flag C from the value of the W accumulator, and put the result of the operation into the REG register.

Before execution:

REG = 1; the value of the REG register is 1.

W = 2; the value of W accumulator is 2.

C = 0; the value of the carry flag C is 0.

After execution:

REG = 0; the value of the REG register is 0.

W = 2; the value of W accumulator is 2.

C = 1; the value of the carry flag C is 1.

Z = 1; the value of zero flag Z is 1.

N = 0; the value of negative flag N is 0.

²The result of the operation is zero.


Command name: SUBLW

Original meaning: Subtract W From Literal

Syntax: [label] SUBLW k

Operator:

Operation description: k – (W) -> W

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

Instruction description: Subtract the constant k from the value of the W accumulator and put the result back into the W accumulator.

Category: Immediate constant addressing method.

Group: Math subtraction instructions.

Example 1:

SUBLW 0x02; Subtract 0x02 from the value of the W accumulator and put the result back into the W accumulator.

[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号