8051 MCU Tutorial Lesson 9: Data Transfer Instructions

Publisher:脑洞飞翔Latest update time:2021-05-08 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Data transfer instructions


1) Instructions with the accumulator as the destination operand


MOVA,Rn


MOVA,direct


MOVA,@Ri


MOVA,#data


In the first instruction, Rn represents R0-R7. In the second instruction, direct refers to the direct address, and in the third instruction, it is what we just talked about. The fourth instruction is to send the immediate data to A.


Let's illustrate this with some examples:


MOVA, R1; send the value in the working register R1 to A, and the value in R1 remains unchanged.


MOVA,30H; send the value in memory unit 30H to A, and the value in unit 30H remains unchanged.


MOVA,@R1; first check the value in R1, take this value as the address, and send the value in this address unit to A. If the value in R1 is 20H before executing the command, the value in the 20H unit is sent to A.


MOVA, #34H; send the immediate number 34H to A. After executing this instruction, the value in A is 34H.


2) Instructions that operate on register Rn


MOVRn,A


MOVRn,direct


MOVRn,#data


The function of this set of instructions is to send the contents of the source address unit into the working register, and the source operand remains unchanged.


MCU Instructions (II)


Data transfer instructions


(3) Instructions with direct address as destination operand MOVdirect,A Example: MOV20H,AMOVdirect,RnMOV20H,R1


MOVdirect1,direct2MOV20H,30H


MOVdirect,@RiMOV20H,@R1


MOVdirect,#dataMOV20H,#34H


(4) Instruction with indirect address as destination operand MOV@Ri,A Example: MOV@R0,AMOV@Ri,directMOV@R1,20H


MOV@Ri,#dataMOV@R0,#34H


(5) The sixteen-digit transfer instruction MOVDPTR, #data168051 is an 8-bit machine. This is the only 16-bit immediate number transfer instruction. Its function is to send a 16-bit immediate number to DPTR. The upper 8 bits are sent to DPH and the lower 8 bits are sent to DPL. For example: MOVDPTR, #1234H, after execution, the value in DPH is 12H and the value in DPL is 34H. Conversely, if we send numbers to DPH and DPL respectively, the result is the same. For example, there are the following two instructions: MOVDPH, #35H, MOVDPL, #12H. It is equivalent to executing MOVDPTR, #3512H. Comprehensive exercises:


Give the result after each instruction is executed


MOV23H,#30HMOV12H,#34H


MOVR0,#23H


MOVR7,#22H


MOVR1,12H


MOVA,@R0


MOV34H,@R1


(23h)=30h


(12h)=34h


(R0)=23H


(R7)=22H


(R1)=12H


(A)=30H


(34H)=34H


MOV45H,34H


MOVDPTR,#6712H


MOV12H, VAT


MOVR0, DPL


MOVA,@R0


(45H)=34H


(DPTR)=6712H


(12H)=67H


(R0)=12H


(A)=67H


Note: The content is represented by brackets, such as (23H) represents the value in the internal RAM 23H unit, and (A) represents the value in the accumulator A unit.


Computer exercises:


Enter DOS state and enter the directory where WAVE is located, for example D:WAVE


Type MCS51


Press File->Open. When the dialog box appears, enter a file name in Name (see Figure 2). If the file already exists in the list below, open the file. If the file does not exist, create a new file.


Enter the above program in the blank space. See Figure 4. Use ALT+A to assemble it. Use F8 to execute it step by step. During the execution, pay attention to the changes in the values ​​of the working register and the A accumulator on the left side of the screen.


The change of the value in the memory cannot be seen here, but can be observed in the following way (see Figure 5): Move the mouse to DATA, double-click, and the cursor will enter this line. At this time, you can use the up and down cursor keys on the keyboard to flip up and down to observe the change of the memory value. The data after the DATA at the front of this line represents the starting address of "a section", such as 20H now. Look at the top of the screen, the numbers from 0 to F, and the sum of the two is equal to the real address value. As shown in the figure, the values ​​of memory 20H, 21H, 22H, and 23H are FBH, 0EH, E8H, and 30H respectively.


Figure 56. After running the program, you will enter its disassembly area, which is not what we want. To start from the beginning, you can use the CTRL+F2 function key to reset the PC value. Note that you will not see the original window at this time. To see the original window, please use ALT+4 or ALT+5 to switch. Of course, the above operations can also be performed through the menu. CTRL+F2 is to reset the program, use the RUN menu. The window uses the WINDOWS menu.


This time, let's get familiar with this software. To be honest, I don't like it very much. It is not convenient to operate, but this is the only software I can use on my machine. I have no choice but to introduce a better one to netizens next time.


Reference address:8051 MCU Tutorial Lesson 9: Data Transfer Instructions

Previous article:Design of Signal Generator Based on FPGA and 51 Single Chip Microcomputer
Next article:8051 MCU Tutorial Lesson 11: Arithmetic Operation Instructions

Recommended ReadingLatest update time:2024-11-16 14:54

Design of C8051 microcontroller to realize multi-target ultrasonic ranging
Ultrasonic ranging sensors are widely used in industrial field ranging, mobile robot navigation and positioning due to their high measurement accuracy, fast response and low price. The commonly used method for ultrasonic ranging sensors is that one transmitter corresponds to one receiving head, and there are also mult
[Microcontroller]
Design of C8051 microcontroller to realize multi-target ultrasonic ranging
Design of real-time measurement and control device based on C8051F020 single chip microcomputer
0 Introduction     The C8051Fxxx microcontroller is a fully integrated mixed-signal system-level chip launched by Silabs, USA, with a CIP-51 core that is fully compatible with the 8051 instruction set. The C8051F020 microcontroller is used in the project development. For technicians who are familiar with the 51 micro
[Microcontroller]
Design of real-time measurement and control device based on C8051F020 single chip microcomputer
DHT11 temperature and humidity sensor driver programming based on C8051F410
This is also a little thing I made during the summer training. I bought some sensors online and spent a lot of money on them, so I used them to practice. The output pin of DHT11 needs to be pulled up with a resistor, which is really troublesome. The program is also not very good. If there is a problem with the conne
[Microcontroller]
8051 single chip infrared remote control experiment
If the web page display format is messed up, you can download the complete source code from here: http://www.51hei.com/f/dpjjmhw.rar // The remote control uses the Ht6221 chip //Infrared remote control Use external interrupt as infrared decoding input Infrared remote control button 1 is the fan start button
[Microcontroller]
8051 single chip infrared remote control experiment
Useful information! 8051 microcontroller's inversion method to scan the keyboard
The keyboard scan uses the inversion method to read the keys: first output zero level from the high 4 bits of port P2, and read the keyboard status from the low 4 bits of port P2; then output zero level from the low 4 bits of port P2, and read the keyboard status from the high 4 bits of port P2. Combining the results
[Microcontroller]
Useful information! 8051 microcontroller's inversion method to scan the keyboard
Design of wireless temperature measurement system based on C8051 and Atmegal6
At present, temperature measurement has been widely used in various fields such as steel, metallurgy, industrial welding, wave soldering, reflow soldering, etc. The temperature to be measured in these applications is very high and the measurement environment is very harsh. Traditional wired temperature measurement
[Microcontroller]
Single chip microcomputer C8051F020 and its application in instruments and meters
1 Introduction At present, with the continuous improvement of science and technology and the level of industrial and agricultural production, higher and higher requirements are put forward for the corresponding instruments and meters. Therefore, instruments and meters need to expand a large number of pe
[Microcontroller]
Embedded Ethernet Monitoring System Based on C8051F020
  introduction   In recent years, with the development of network technology, networking has swept the world. How to connect instruments and equipment such as measurement and control systems to the Internet in industrial sites to achieve information sharing and remote control has become a topic of concern. The bus t
[Microcontroller]
Embedded Ethernet Monitoring System Based on C8051F020
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号