51 MCU instruction mnemonics and their related symbols memory method

Publisher:JoyfulExplorerLatest update time:2015-03-25 Source: diangon Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
  As we all know, assembly language instructions consist of two parts: opcode and operand. MCS-51 uses assembly language instructions, which has 44 opcode mnemonics and 33 functions. Its operands include #data, direct, Rn, @Ri, etc. Here we first introduce the memory method of instruction mnemonics and their related symbols.

  1. How to memorize mnemonics

  1 Tabular enumeration method

  The 44 instruction mnemonics are divided into five categories according to their functions, and each category is memorized in a list. I will omit them here and ask the reader to summarize them by himself.

  2 English Restoration Method

  The operation code mnemonics of the microcontroller are the English abbreviations of the instruction functions. Converting the abbreviations into the original English text and comparing them with the Chinese text will help you understand the meaning of the mnemonics and thus strengthen your memory. For example:

  Increment INC-Incremect Decrement DNC-Decrement Short jump SJMP-Short jump Long jump LJMP-Long jump Compare jump CJNE-Compare jump not equality Absolute jump AJMP-Absolute jump No operation NOP-No operation Exchange XCH-Exchange Addition ADD-Addition Multiplication MUL-Multiplication Division DIV-Division Rotate left RL-Rotate left carry RLC-Rotate left carry RR-Rotate right carry RRC-Rotate right carry

  3 Functional module memory method

  The 44 instruction mnemonics of the microcontroller 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, the whole can be broken down into parts, and each can be defeated one by one to achieve rapid memorization.

  1) Data transmission group

        2) Addition and subtraction operation group: MOV internal data transfer ADD addition MOVC program memory transfer ADDC with carry addition MOVX external data transfer SUBB with carry subtraction

     3) Logical operation group

     4) Subroutine call group: ANL logical AND LCALL long call ORL logical OR ALALL absolute call XRL logical exclusive OR RET subroutine return

  2. How to memorize instructions

  1 Symbols related to instruction operands

  There are six addressing modes in MCS-51: immediate addressing, direct addressing, register addressing, inter-register addressing, indexed addressing, and relative addressing. We must master their representation methods.

  1) Immediate value and direct address. ata indicates an eight-bit immediate value, #data16 indicates a sixteen-bit immediate value, and data or direct indicates a direct address.

   2) Rn (n=0-7), A, B, CY, DPTR register addressing variables.

  3) @R0, @R1, @DPTR, SP represent register address variables.

   4) DPTR+A, PC+A represent variables with displacement addressing.

   5) PC + rel (relative quantity) indicates a relative addressing variable.

  Remembering the mnemonics of instructions and mastering the representation methods of instruction operands in different addressing modes lays 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 instructions, 24 arithmetic operations, 25 logical operations, 17 control transfer instructions, and 17 Boolean bit operations. In each category of instructions, according to its function, grasp the different combinations of its source and destination operands, and then use the following methods to remember it. We agree that the possible destination operands are represented in the order of (#data/direct/A/Rn/@Ri).

  For MOV instructions, the destination operand is written in the order of A, Rn, direct, @Ri, and you can remember the 15 MOV instructions. For example, with accumulator A as the destination operand, you can write the following 4 instructions.

  MOV A,# data/direct/A/Rn/@Ri

   And so on, write other instructions.

   MOV Rn,#data/direct/A

   MOV direct, #data/direct/A/Rn/@Ri

   MOV @Ri,#data/direct/A

  2. Instruction Graphic Memory Method

  The graphic mnemonic method is a mnemonic method that uses graphics and arrows to represent the relationship between the destination and source operands of instructions with the same or similar operating functions but different operands. For example, the instruction to send an array composed of the mnemonics MOV, MOVX, and MOVC can be memorized using Figures 1 and 2.

  The four instructions formed by the mnemonic CJNE can also be represented by a diagram, as shown in Figure 3. 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 ring shift instructions related to A can also be represented by diagrams. Readers are requested to draw them and memorize them by themselves.

  3. Classification of similar functions

  In the MCS-51 instructions, we found that some instructions have different opcodes, but similar functions and the same operands. The similar function classification method is to memorize instructions with such characteristics together. As long as you remember one of them, you can remember the rest. For example, there are twelve instructions for addition and subtraction, and eighteen instructions for AND, OR, and NOT, which are listed below. ADD/ADDC/SUBB A, # data/direct/Rn/@Ri

  ANL/ORL/XRL A,# data/direct/Rn/@Ri

  ANL/ORL/XRL direct, #data/a

  Each row of instructions above has similar functions and the same operands. Other instructions such as addition (INC) and subtraction (DEC) can also be handled in the same way.

  4. Mnemonics

  For some instructions, we can use concise language to compile the related functions into a sentence to memorize. For example, the two instructions PUSH direct and POP direct. Beginners often cannot distinguish the changes in the stack SP, so we compile a sentence like this: (the content of SP) plus 1 (the content of direct) and then push it into the stack, (the content of SP) is popped (to the direct unit) SP is then reduced by 1. For example, the storage of the product in the multiplication instruction, the storage of the dividend, divisor and quotient in the division instruction, can all be compiled into a mnemonic to memorize as follows: MUL AB

  The high-order product is stored in B, and the low-order product is stored in A.

  DIV AB

  When A is divided by B, the quotient is stored in A and the remainder is B.

  The above introduces several methods of quickly memorizing microcontroller instructions. I hope it can serve as a starting point for discussion. I believe that readers can find a method that suits them in the process of learning microcontrollers. However, having a good method is not enough. Practice is also needed. That is, read more examples in books and programs written by others, and then write some programs yourself based on actual practice. Only in this way can you master the microcontroller instruction system better and faster.

  Expert advice

  When you first start learning microcontrollers, you must understand some digital circuits. If you are not familiar with the general concepts of digital circuits, it is best to take some extra lessons before learning microcontrollers. Next, you'd better choose a type of microcontroller to learn, because there are many types of microcontrollers at present, and their structures and instructions are different. If you learn one for two days and another for two days, you will often not be able to digest it. It is recommended that you first learn 8051 microcontrollers, because there are many books, materials, and equipment related to 8051. Although PIC, AVR and other types of microcontrollers have their advantages, the current supply of books, materials and devices is not ideal, and they are not suitable for beginners. If you don't care about these, it is not a bad idea to choose the latter to learn.

  The reason why we recommend that you choose 8051 microcontroller to start learning is that there are many derivatives of the 8051 family. For example, ATMEL's AT89C51 series microcontrollers are fully compatible with the MSC-51 8051 series (that is, the AT89C51's instructions, pins, internal main structure, and usage are the same as the MSC-51). Not only is it compatible, but it also has many innovations. For example, its program memory can be electrically erased and written. A single IC has the smallest system of a single-chip microcomputer in the past, and there is no need for the so-called 373 and EPROM components in the past. Therefore, it is relatively easy to connect circuits and make circuit boards during experiments. In addition, its price is relatively low at present. The chips you study can also be used to make products, and the chips used to make products can also be used for experiments. Of course, the AVR series also has these characteristics; PIC and other series are not ideal in this regard.

Reference address:51 MCU instruction mnemonics and their related symbols memory method

Previous article:MCU interface principle circuit diagram
Next article:8051 MCU pin diagram and pin functions

Latest Microcontroller Articles
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号