MCS-51 refers to the general name of a series of single-chip microcomputers produced by the United States INTEL. This series of single-chip microcomputers includes many varieties, such as 8031, 8051, 8751, 8032, 8052, 8752, etc., of which 8051 is the earliest and most typical product.
Everyone knows that assembly language instructions are composed of two parts: opcode and operand. MCS-51 uses assembly language instructions, it has a total of 44 opcode mnemonics, 33 functions, and its operands include #data, direct, Rn, @Ri, etc. Here we first introduce the memory method of instruction mnemonics and related symbols.
1. The memory method of mnemonic symbols
1. Table listing method
The 44 instruction mnemonics are divided into five categories according to their functions, and each category is memorized in a list. This is omitted here, and readers are invited to summarize by themselves.
2. English reduction method
The operation code mnemonic of the single-chip microcomputer is the English abbreviation of the instruction function. The abbreviation is restored to the original English, and then the Chinese is helpful to understand the meaning of the mnemonic, thereby strengthening the memory. E.g:
Increment INC-Incremect Decrement DNC-Decrement Short transition SJMP-Short jump Long transition LJMP-Long jump Comparison transition CJNE-Compare jump not equality Absolute transition AJMP-Absolute jump No operation NOP-No operation exchange XCH-Exchange addition ADD-Addition Multiplication MUL-Multiplication Division DIV-Division Left ring shift RL-Rotate left Carry left ring shift RLC-Rotate left carry Right ring shift RR-Rotate right Carry right ring shift RRC-Rotate right carry
3. Function module memory method
The 44 instruction mnemonics of the single-chip microcomputer can be divided into five categories according to their instruction functions, and each category can be divided into 2 to 3 groups according to the principle of similar functions. In this way, it is broken into parts, and each is broken to realize fast memory.
1) Data transfer group
2) Addition and subtraction operation group:
MOV internal data transfer ADD addition MOVC program memory transfer ADDC addition with carry MOVX external data transfer SUBB subtraction with carry
3) Logic operation group
4) Subroutine call group:
ANL logic and LCALL long call ORL logic or ALALL absolute call XRL logic exclusive OR RET subroutine return
2. Memory method of instructions
1. Relevant symbols of instruction operands
MCS-51 has six addressing modes: immediate addressing, direct addressing, register addressing, register indirect addressing, indexed addressing, and relative addressing. We must master the method of expression.
1) Immediate data and direct address. ata means eight-digit immediate data, #data16 means sixteen-digit immediate data, and data or direct means direct address.
2) Rn (n=0-7), A, B, CY, DPTR register addressing variables.
3) @R0, @R1, @DPTR, SP represent indirect register address variables.
4) DPTR+A, PC+A represent the variables of indexed addressing.
5) PC+rel (relative quantity) represents relative addressing variables.
Remembering the mnemonics of instructions and mastering the representation methods of instruction operands in different addressing modes have laid the foundation for us to memorize assembly instructions. Although there are many MCS-51 instructions, they can be divided into five categories according to their functions, including 28 data transfer, 24 arithmetic operations, 25 logic operations, 17 control transfers, and 17 Boolean operations. In each type of instruction, according to its function, grasp the different combination of its source and destination operands, and supplement the following methods, it is completely memorable. We agree that the possible destination operands are expressed in the order of (# data/direct/A/Rn/@Ri ).
For the MOV instruction, the destination operand is written in the order of A, Rn, direct, @Ri, and 15 MOV instructions can be remembered. For example, with accumulator A as the destination operand, the following 4 instructions can be written.
MOV A, # data/direct/A/Rn/@Ri and so on, write other commands. MOV Rn, #data/direct/AMOV direct, # data/direct/A/Rn/@RiMOV @Ri, #data/direct/A
2. Instruction icon memory method
Graphical memory method is a memory method that uses graphics and arrows to show the relationship between the destination and source operands for instructions with the same or similar operating functions but different operands.
The four instructions formed by the mnemonic CJNE can also be represented graphically. CJNE A, #data, rel CJNE A, direct, rel CJNE @Rn, #data, rel CJNE @Ri, #data, rel
In addition, for the 18 logical operation instructions formed by (ANL, ORL, ARL), the four circular shift instructions related to A can also be represented by diagrams. Readers are asked to draw their own memories.
3. Classification of similar functions
In the MCS-51 instruction, we found that some instructions have different opcodes but similar functions, but the operands are exactly the same. The similar function classification method is to memorize the instructions with such characteristics together, as long as one of them is memorized, the rest will also be memorized. The twelve instructions for addition and subtraction, and the eighteen instructions for AND, OR, and NOT are listed below.
ADD/ADDC/SUBB A, # data/direct/Rn/@RiANL/ORL/XRL A, # data/direct/Rn/@RiANL/ORL/XRL direct, #data/a
Each row of instructions above has similar functions, and their operands are all the same. Other instructions such as plus 1 (INC) and minus 1 (DEC) can also be handled in this way.
4. Mantra memory method
For some instructions, we can use concise language to compile related functions into one sentence to remember. Such as PUSH direct and POP direct two instructions. Beginners often can’t distinguish the changes of the stack SP, so we compose this sentence: (SP content) plus 1 (direct content) and then stack, (SP content) pops (to the direct unit) SP is reduced 1. Another example is the storage of the product in the multiplication instruction, the storage of the dividend and the divisor and the quotient in the division instruction, which can all be compiled into a formula memory as follows:
MUL AB high-order product (stored in) B, low-order product (stored in) A. Divide ABA by B, quotient (stored in) A and remain (below) B.
The above introduces several methods of quickly memorizing the instructions of the single-chip microcomputer, hoping to play a role in attracting new ideas, I believe that readers can find a method suitable for them to remember in the process of learning the single-chip microcomputer. However, it is not enough to have a good method. Practice is also needed, that is, read more examples and programs written by others, and write some programs in combination with actual practice. Only in this way can we master the instruction system of the microcontroller better and faster.
Suggest
At the beginning of learning a single-chip microcomputer, you must understand some digital circuits. If you are very vague about the general concepts in digital circuits, it is best to learn more about the single-chip microcomputer. Next, you'd better choose a type of single-chip microcomputer to study, because there are many types of single-chip microcomputers, and their structures and instructions are different. If you study this for two days, you will often not chew for two days. .
It is recommended that you learn 8051 MCU first, because there are more books, materials, and equipment on 8051. Although PIC and AVR and other types of single-chip microcomputers have their advantages, the current supply of books, materials and devices is not ideal, and it is not suitable for beginners to choose. If you don't care about these, then choosing the latter to study is not yet impossible.
We recommend that you choose the 8051 MCU to start learning because there are many derivatives of the 8051 family. For example, ATMEL’s AT89C51 series MCU is fully compatible with the MSC-51 8051 series (that is, AT89C51 commands, pins, and main internal structures). , And the usage is the same as MSC-51), it is not only compatible, but also has a lot of innovations. For example, its program memory can be erased and written. One IC has the smallest system of the past single-chip microcomputer, without the so-called 373 and EPROM components; therefore, it is easier to connect the circuit and make the circuit board during the experiment. In addition, the current price is relatively low. You can also make products for the films you study, and you can also do experiments for the products. Of course, the AVR series also have these characteristics. ; PIC and other series are not ideal at this point.
It’s best to buy a book for the MCU if you can read the front of the book, but you don’t understand the back of the book. If you don’t understand the book before and after, it’s best not to buy it first, because this book won’t be of much interest to you in a short time. effect. Of course, if you don’t use the book as a reference, you don’t have to buy a book that you know before and after, because it’s a bit shallow for you. Should be based on principle books. Secondly, you can buy some application books for reference.
Electronic technology itself is inseparable from experiments. It is difficult to understand its principles and learn how to develop microcontrollers by reading books. You should purchase the relevant microcontroller chip, programmer, experiment board, and develop his related software. The effect of learning while reading a book while experimenting will be significantly better! Because of beginners, it is impossible to purchase many expensive equipment. It is recommended that the MCU chip for learning has a program memory that can be repeatedly rewritable, such as the AT89C series Or AVR series. In this way, there is no worries when learning to program.
Now let's talk about the steps of MCU development. If you want the single-chip microcomputer to complete a task according to your meaning (idea), you must first write a program for its use. The program for the single-chip microcomputer should use a "language" that the single-chip microcomputer can recognize, otherwise you will play the piano against the "stone". At present, assembly language and C language are more popular; assembly language can precisely control each step of the microcontroller's work, while C language focuses on the results and does not need to care about each step of the microcontroller.
It is customary to learn assembly language first and then C language, so that you can have a deeper understanding of the single-chip microcomputer. Besides, it is to use C language to program, and you need to embed assembly statements when precise control is required. Of course, I also used the C language at the beginning, and later learned assembly; if you have learned Turbo C for computers, it may be faster to learn C for microcontrollers at the beginning.
The MCU program is a plain text file written with a text editor. Just like we usually write plans in Chinese in a windows notebook, write this matter first and then that matter. Use the grammar of the single-chip microcomputer language according to our The idea is to write down the things to be done by the microcontroller "one by one" one by one. When "some things" are repeated, indicate where there is an explanation (jump). If there are other surprises in the normal arrangement When an incident occurs, you must write an emergency incident handling plan (interruption).... Finally, the extension of the saved file should be consistent with the name required by the language used; our Chinese articles are generally saved as *.txt extension, while the file extension of assembly language should generally be *.asm; some development systems have Own regulations, such as Keil C51 development system, the extension of the compiled assembler is *.a51; of course, Keil C51 development system also has its own editor, no need to use Notepad in Windows.
Regardless of whether we use assembly language or a program written in C language, it is just for us to see. This program must also be “translated†(compiled) from assembly or C that we can understand into the microcontroller that can be recognized by the software corresponding to the language. Code. Write (program) the code that the single-chip microcomputer can recognize into the program memory of the single-chip microcomputer, and the actual circuit installed in the single-chip microcomputer can work according to your "plan".
For the 8051 series single-chip microcomputers, the Keil C development system has the functions of editing, compiling, and simulating the C language program of the single-chip microcomputer. It can also edit, compile and simulate assembly language programs; for beginners, it is inevitable that there will be grammatical errors or other inaccuracies in the programs they start to write. The standard statement, because Keil C compiles the error statement in English, which is not easy to understand. If you use assembly, you can use the macro assembler ASM51 under DOS; he can prompt the error statement in Chinese; your source program You can also use Chinese in the comment part of, which makes it easier for you to maintain the program in the future.
The compiled code generally has an extension of *.hex or *.bin; this code file must be sent to the single-chip microcomputer in the circuit to work according to your "plan". The tool that sends this code file to the microcontroller is the programmer. The programmer connected to the computer is generally connected to the hardware of the programmer through a parallel port or a serial port, and there is also a corresponding service program; run its service program after connecting the computer and programming , In the service program, first select the MCU model to be programmed, and then load the code file obtained before, and then use the programmer to program the code file into the MCU. At this point, a process of microcontroller development is roughly completed.
Of course, you cannot write your "plan" perfectly and correctly in the language of the single-chip microcomputer at one time (that is, the plan we usually make is also modified in practice), which requires repeated modification of the source program and repeated compilation , Burn into the single chip microcomputer, repeatedly install the single chip microcomputer into the circuit to experiment. Because the time taken by the single-chip microcomputer to execute each statement is very short, sometimes you cannot get the intermediate results, nor can you judge the location of the program error. At this time, you can use the software simulation method to make the program execute step by step. By looking at the changes in the key data in the single-chip microcomputer, you can find errors or statements that are not executed according to your "plan", so as to achieve the purpose of troubleshooting. If your funds are not a problem, you can also buy a single-chip simulator, which can replace the single-chip in the actual circuit and troubleshoot the next step under the control of the computer. In fact, whether software simulation (emulation) or hardware simulation, its function is far more than the point mentioned here.
Uv Air Purifier,Air Purifier With Uv Light,Uvc Air Purifier,Uv Air Cleaner
CIXI KYFEN ELECTRONICS CO.,LTD, , https://www.kyfengroup.com