1. Internal data transfer instructions
1. MOV instruction
① MOV R0 , #20H
# is followed by an immediate number, which should be distinguished from the address. 20H is a hexadecimal number. This sentence means to send the number 20H to register R0. Direct addressing
② MOV 30H , @R0
The number in R0 is given to the address 30H with this digital address.
③MOV C, 20.4H
Bit addressing, this C is the highest bit in the PSW program status word, CY is the carry bit, and the borrow bit.
2. Access external RAM memory
① MOV DPTR, #1234H
DPTR is divided into DPH and DPL (high 8 bits and low 8 bits), which are stored in the SFR of the internal RAM. The function of this sentence is to give the immediate value to DPTR.
② MOVX A, @DPTR
The purpose of this sentence is to take out the number pointed to by DPTR from the external RAM and give it to A, reading from the external memory.
Read operation process (automatically completed): the value in DPH is sent to A15-A8 through the address bus, and then the value in DPL is sent to P0 port. ALE sends a latch signal (a high pulse signal) and the latch changes to the level of P0 port. After that, RD sends another read signal (a low level pulse), and the data is sent to P0 port through the data bus, and finally to A. Here, P2 port acts as the high eight bits of the address, and P0 port is time-division multiplexed through a latch, acting as both the low eight bits of the address and the digital bit.
③INC DPTR
Function: DPTR plus one
④MOVX @DPTR, A
Write the value of A to the address corresponding to DPTR
⑤MOV R0, #44H
Function: Store 44H in R0
⑥MOVX A, @R0
Function: Read external RAM
Key point: MOVX requires a 16-bit address when operating externally. If there are only 8 bits, the lower eight bits of the address will be retained while the higher eight bits will be kept.
There are only three ways to access external RAM: ①DPTR ②R0 ③R1
The address can only be set through these three. Using R0 and R1 is called page addressing, and it can only determine port P0, which is the lower eight bits of the address.
256 x 256 = 65536
Page Address within the page
3. Get data from ROM
ROM is a read-only memory that can only perform read operations but not write operations.
There are only two reading methods: ① MOVC A, @A+DPTR ② MOVC A, @A+PC
DPTR and PC are both 16 bits, and the accessible range is 64K
There are two methods:
1. Remote meter query
MOV A, #00H
MOV DPTR, #1234H
MOVC A,@A+DPTR
By assigning a value to DPTR, a table lookup can be performed at any position.
2. Short-range table lookup
MOV A,#00H
MOVC A, @A+PC
MOV 30H, A
Because A is 8 bits, it can only be changed at the current PC position.
2. 7 addressing methods
1. Immediate addressing
MOV A, #00H
MOV 30H, #33H
MOV DPTR, #1234H
2. Direct addressing
MOV A, 3AH
MOV 30H, 33H is translated into machine code 85 33 30
Direct addressing accesses the SFR address
3. Register addressing
MOV A ,R0
MOV A,R1
INC R1
4. Register indirect addressing (only R0 and R1 can be used)
MOV A,@R0
MOV A ,@R1
INC @R1
Read external RAM
MOVX A, @R0
MOVX A, @R1
Writing external ROM
MOVX @R0, A
MOVX@DPTR,A
MOVX A, @DPTR
MOVX@DPTR,A
5. Relative addressing
JC 80H 80H–>rel
Function: Jump if C is 1 rel: 8-bit signed offset address
PC destination = PC current + rel
6. Indexed addressing
MOVC A, @A+DPTR
MOVC A, @A+PC
JMP @A+DPTR
7. Bit addressing
MOV C, 00H
MOV ACC.5 C
CPL C
Previous article:51 MCU Principle and Assembly Tutorial (I) 51 MCU Structure and Principle
Next article:51 MCU - Serial Communication
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- 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
- 1602 display dht11 temperature and humidity
- CircuitPython 6.1.0 released
- 【RT-Thread Reading Notes】+ Pain and Happiness
- Data acquisition technology based on SDI-12 bus (communication protocol)
- 04. WS2812B driver implementation of SPI
- In-depth disassembly | The magical use of Qorvo chips in handheld vacuum cleaners
- Please ask a MicroPython question
- Learning experience of MSP430F5529 clock module
- Noise suppression solution example in automotive power circuits
- How can wireless monitoring systems minimize latency?