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:
Previous article:Ultrasonic PIC microcontroller C program
Next article:Single chip microcomputer EC1 digital rotary encoder simulation program
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- How does the uart.write function output three bytes of 0XFF 0XFF 0XFF (HEX data, not string data)?
- Chinese programmers VS American programmers, so vivid...
- The last version of Python2, Python 2.7.18, was released
- Unboxing the Renesas CPK-RA2L1 development board and preparing for evaluation
- DSP5402 development board schematic diagram
- Please tell me the setting function of deep sleep
- Driver transplantation of pedometer bracelet based on F103 and X-NUCLEO-IKS01A3
- [Jihai APM32E103VET6S Development Board] Review 1. Unboxing
- Using LM339 to generate triangle wave
- Are there any homemade downloaders such as st-link and j-link?