PIC microcontroller assembly language explanation (Part 1)

Publisher:美丽花朵Latest update time:2020-02-28 Source: eefocusKeywords:pic Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

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.

Keywords:pic Reference address:PIC microcontroller assembly language explanation (Part 1)

Previous article:Summary of modules and functions of PIC microcontrollers
Next article:PIC microcontroller assembly language explanation (Part 2)

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号