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

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

C = DC = N = OV = Z = 0; Assume that the flags in the status register are all 0.

After execution:

W = 0x80; the value of W accumulator is 0x80.

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

N = 1, Z = C = DC = OV = N = 0; Since the 7th bit after the operation is equal to 1, the negative flag N is set to 1.


Instruction name: LFSR

Original meaning: Load FSR

Syntax: [label] LFSR f, d

Operator:

Operation description: k -> FSRf

Impact flags: None

Instruction description: In addition to direct addressing and immediate addressing, the PIC single chip has another way of addressing data, which is indirect addressing. The base register used for indirect addressing is the FSR (File Select Register) register. The register stores the address, which is the address of the data. As for the data, it is placed in the temporary register INDF. For example, if we want to put the data 0x30 in the RAM address 0x100, we only need to store 0x100 in it. In the FSR temporary register, just store 0x30 in the INDF temporary register. In the PIC18 series, there are three FSR temporary registers that can be used for indirect addressing, namely FSR0, FSR1 and FSR2. The defined memory address length can reach 12 bits, but the length of the temporary register There are only 8 bits, so FSR0 is divided into FSR0H and FSR0L, FSR1 is divided into FSR1H and FSR1L, and FSR2 is divided into two high and low bit registers, FSR2H and FSR2L. If we want to put the RAM address 0x180 in FSR2, we can write it as LFSR 2,0x180; if we want to put the RAM address 0x2AB in FSR0, we can write it as LFSR 0,0x2AB.

Category: Immediate constant addressing method.

Group: Numerical operation instructions.

Example 1:

LFSR 0,0x423

Before execution:

FSR0H = ?

FSR0L = ?


After execution:

FSR0H = 0x04

FSR0L = 0x23

Example 2:

LFSR 2,0x3AB

Before execution:

FSR2H = ?

FSR2L = ?

After execution:

FSR2H = 0x03

FSR2L = 0xAB


Command name: MOVF

Original meaning: Move f

Syntax: [label] MOVF f, d

Operator:

Operation description: f -> dest

Impact flags: N, Z

Instruction description: Move the value of register (f) to the register specified by 'd'. 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: Data transfer instructions.

Group: Data move instructions.

Example 1:

MOVF REG,W; transfer the value of the temporary register REG to the W accumulator.

Before execution:

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

W = 0x02; the value of W accumulator is 0x02.

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

After execution:

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

W = 0x00; the value of W accumulator is 0x00.

Z = 1, N = 0; the result is equal to 0, so the zero flag Z is equal to 1.

Example 2:

MOVF REG,F; transfer the value of register REG to register REG.

Before execution:

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

W = 0x02; the value of W accumulator is 0x02.

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

After execution:

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

W = 0x02; the value of W accumulator is 0x02.

N = 1, Z = 0; since the 7th bit is 1, the negative flag N is equal to 1.

Example three:

MOVF REG,W; transfer the value of the temporary register REG to the W accumulator.

Before execution:

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

W = 0x30; the value of W accumulator is 0x30.

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

After execution:

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

W = 0x80; the value of W accumulator is 0x80.

N = 1, Z = 0; since the 7th bit is not 1, the negative flag N is equal to 0; the result after the transfer is not 0, so the zero flag Z is equal to 0.


Command name: MOVFF

Original meaning: Move f to f

Syntax: [label] MOVF   

Operator:

Operation description:

Impact flags: None

Instruction description: Transfer the value of the temporary register to the temporary register .

Category: Data transfer instructions.

Group: Data move instructions.

Example 1:

MOVFF REG1, REG2; transfer the value of register REG1 to register REG2.

Before execution:

REG1 = 0x03; the value of temporary register REG1 is 0x03.

REG2 = 0x80; the value of temporary register REG2 is 0x80.

After execution:

REG1 = 0x03; the value of temporary register REG1 is 0x03.

REG2 = 0x03; The value of temporary register REG2 is 0x03.

Example 2:

MOVFF REG1,PORTB; transfer the value of the temporary register REG1 to PORTB.

Before execution:

REG1 = 0x03; the value of temporary register REG1 is 0x03.

PORTB = 0x80; The value of PORTB is 0x80.

After execution:

REG1 = 0x03; the value of temporary register REG1 is 0x03.

PORTB = 0x03; The value of PORTB is 0x03.


Instruction name: MOVLB

Original meaning: Move literal to low nibble in BSR

Syntax: [label] MOVLB k

Operator:

Operation description: k -> BSR

Impact flags: None

Instruction description: Move constants to the Bank Select Register (BSR) to set the starting address for accessing data. Because the RAM is divided into many pages for our use in 18FXX2, if the BSR is equal to 1, it means that the access address starts from 0x100; after the system starts or after RESET, the BSR is defaulted to 0, which means starting from 0x00.

Category: Immediate constant addressing method.

Group: Data move instructions.

Example 1:

MOVLB 1; transfer the constant to the temporary register BSR.

Before execution:

BSR = 0x00; The value of the temporary register BSR is 0x00.

After execution:

REG1 = 0x01; the value of the temporary register BSR is 0x01.


Command name: MOVLW

Original meaning: Move literal to W

Syntax: [label] MOVLW k

Operator:

Operation description: k -> W

Impact flags: None

Instruction description: Move the constant to the W accumulator.

Category: Immediate constant addressing method.

Group: Data move instructions.

Example 1:

MOVLW 0x40; Move the constant 0x40 to the W accumulator.

Before execution:

W = 0x00; the value of W accumulator is 0x00.

After execution:

W = 0x40; the value of W accumulator is 0x40.


Command name: MOVWF

Original meaning: Move W to f

Syntax: [label] MOVWF f

Operator:

Operation description: (W) -> f

Impact flags: None

Instruction description: Move the value in the W accumulator to the temporary register REG.

Category: Data transfer instructions.

Group: Data move instructions.

Example 1:

MOVWF REG; Move the value in the W accumulator to the temporary register REG.

Before execution:

W = 0xF0; the value of W accumulator is 0xF0.

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

After execution:

W = 0xF0; the value of W accumulator is 0xF0.

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


Command name: MULLW

Original meaning: Multiply Literal with W

Syntax: [label] MULLW k

Operator:

Operation description: (W) xk -> PRODH : PRODL

Impact flags: None

Instruction description: Multiply the constant by the value in the W accumulator, and put the result into the two 8-bit temporary registers PRODH: PRODL.

Category: Immediate constant addressing method.

Group: Mathematical operation multiplication instructions.

Example 1:

MULLW 0x10; Multiply the constant 0x10 with the value in the W accumulator.

Before execution:

W = 0x02; the value of W accumulator is 0x02.

PRODH = ? ; assuming the value of PRODH is unknown.

PRODL = ? ; Assume that the value of PRODL is unknown.

After execution:

W = 0x02; the value of W accumulator is 0x02.

PRODH = 0x00; the value of PRODH is 0x00.

PRODL = 0x20; PRODL value is 0x20.

Example 2:

MULLW 0xC4; Multiply the constant 0xC4 with the value in the W accumulator.

Before execution:

W = 0xE2; the value of W accumulator is 0xE2.

PRODH = ? ; assuming the value of PRODH is unknown.

PRODL = ? ; Assume that the value of PRODL is unknown.

After execution:

W = 0xE2; the value of W accumulator is 0xE2.

PRODH = 0xAD; the value of PRODH is 0xAD.

PRODL = 0x08; the value of PRODL is 0x08.


Command name: MULWF

Original meaning: Multiply W to f

Syntax: [label] MULWF f

Operator:

Operation description: (W) x (f) -> PRODH : PRODL

Impact flags: None

Instruction description: Multiply the value in the temporary register with the value in the W accumulator, and put the result into the two 8-bit temporary registers PRODH: PRODL.

Category: Data transfer instructions.

Group: Mathematical operation multiplication instructions.

Example 1:

MULWF REG; Multiply the value of the temporary register REG with the value in the W accumulator.

Before execution:

W = 0x02; the value of W accumulator is 0x02.

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

PRODH = ? ; assuming the value of PRODH is unknown.

PRODL = ? ; Assume that the value of PRODL is unknown.

After execution:

W = 0x02; the value of W accumulator is 0x02.

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

PRODH = 0x00; the value of PRODH is 0x00.

PRODL = 0x40; the value of PRODL is 0x40.

Example 2:

MULWF REG; Multiply the value of the temporary register REG with the value in the W accumulator.

Before execution:

W = 0xC4; the value of W accumulator is 0xC4.

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

PRODH = ? ; assuming the value of PRODH is unknown.

PRODL = ? ; Assume that the value of PRODL is unknown.


After execution:

W = 0xC4; the value of W accumulator is 0xC4.

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

PRODH = 0x8A; The value of PRODH is 0x8A.

PRODL = 0x94; the value of PRODL is 0x94.

Example three:

MULWF REG; Multiply the value of the temporary register REG with the value in the W accumulator.

Before execution:

W = 0x10; the value of W accumulator is 0x10.

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

PRODH = ? ; assuming the value of PRODH is unknown.

PRODL = ? ; Assume that the value of PRODL is unknown.

After execution:

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