Pic microcontroller is one of the most commonly used microcontrollers, and many programs are developed based on pic microcontrollers. Therefore, it is particularly important to be proficient in pic microcontroller programming. In order to ensure that everyone can accurately and proficiently master the use of pic microcontrollers, this article brings the first part of the explanation of various assembly language instructions of pic microcontrollers, and the second part will be explained in a later article. If you are interested in the content of this article, you may wish to continue reading.
1. PIC instruction system
PIC8-bit microcontroller has three levels, with corresponding instruction sets. The basic PIC series chip has 33 instructions, each with a 12-bit word length; the intermediate PIC series chip has 35 instructions, each with a 14-bit word length; the advanced PIC series chip has 58 instructions, each with a 16-bit word length. Its instructions are backward compatible.
2. PIC assembly language instruction format
The PIC series microcontroller assembly language instructions are the same as the MCS-51 series single-chip assembly language. Each assembly language instruction consists of 4 parts, and its writing format is as follows:
Label opcode mnemonic operand1, operand2; comment
The instruction format is described as follows: The four parts of the instruction are separated by spaces, which can be one or more spaces, to ensure that the PC can recognize the instruction during cross assembly.
1. Labels
have the same function as MCS-51 series microcontrollers. Labels represent the symbolic address of instructions. When the program is assembled, the specific value of the instruction memory address has been assigned. The symbolic address (i.e. label) used in assembly language is convenient for viewing and modification, especially for the representation of instruction transfer addresses. Labels are optional in the instruction format and are only required when referenced by other statements. In the absence of a label, one or more spaces must be reserved before the instruction mnemonic before writing the instruction mnemonic. The instruction mnemonic cannot occupy the position of a label, otherwise the mnemonic will be mishandled as a label by the assembler.
When writing a label, the first character must be a letter or a half-width underscore "—", which can be followed by English and numeric characters, colons (:), and symbols, and can be combined in any way. In addition, labels cannot be represented by opcode mnemonics and register codes. Labels can also occupy a single line.
2. Operation code mnemonic
This field is a mandatory item for instructions. This item can be an instruction mnemonic, or it can be composed of pseudo instructions and macro commands. Its function is to compare the "instruction operation code mnemonic" with the "operation code table" one by one during cross assembly to find out the corresponding machine code and generate them one by one.
3. The operand
consists of the data value of the operand or the data or address value represented by the symbol. If there are two operands, the two operands are separated by a comma (,). When the operand is a constant, the constant can be binary, octal, decimal or hexadecimal. It can also be a defined label, string and ASCII code. When it is specifically expressed, it is stipulated that the letter "B" is prefixed before the binary number, such as B10011100; the letter "O" is prefixed before the octal number, such as O257; the letter "D" is prefixed before the decimal number, such as D122; and the letter "H" is prefixed before the hexadecimal number, such as H2F. Here, the default system of the PIC8-bit microcontroller is hexadecimal. Add Ox before the hexadecimal number, such as H2F can be written as Ox2F.
The operands of the instruction are also optional.
The PIC series, like the MCS-51 series 8-bit microcontrollers, has addressing methods, that is, the source or destination of operands. Because the PIC series microcontrollers use a reduced instruction set (RISC) architecture, their addressing methods and instructions are few and simple. Its addressing methods can be divided into four types according to the source of the operands: immediate addressing, direct addressing, register indirect addressing, and bit addressing. Therefore, the operands in the instructions of the PIC series microcontrollers often have related register symbols. Relevant addressing examples can be found later in this article.
4. Comments
are used to explain the program and make it easier for people to read the program. Use a semicolon (;) to separate the comment from other parts. When the assembler detects a semicolon, the characters after it are no longer processed. It is worth noting that when using a subroutine, the entry condition, exit condition, and the function and effect that the program should complete should be stated.
The above is the relevant content of "pic microcontroller" brought by the editor this time. Through this article, I hope everyone can have a preliminary understanding of the use of assembly language of pic microcontroller. In the later articles, the editor will bring you the next part of this article. If you are interested in the assembly content, please pay attention.
Previous article:Summary of modules and functions of PIC microcontrollers
Next article:PIC microcontroller assembly language explanation (Part 2)
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- 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
- A few pictures help you easily understand DDR crosstalk
- cs+ cannot simulate debugging
- Share a long filter design guide
- C language STM8 program help
- Will Wi-Fi 6 replace Wi-Fi 5 as the mainstream wireless standard?
- Considerations for Successive Approximation Register ADC Input
- Today's live broadcast: The new Infineon MOSFET based on Source-down technology effectively improves power density, which is visible to the naked eye
- DIY a WS2812 clock
- [NUCLEO-L552ZE Review] Unboxing and Onboard Resource Analysis
- [Xianji HPM6750 Review] PWM Control Buzzer Sound