Microcontroller programming: Find the maximum number and store it in the BIG unit.
Assume that the internal RAM stores a group of unsigned numbers starting from the LIST unit, with the number of data being 30. Program to find the maximum number and store it in the BIG unit.
;----------------------------------------------------------------
Best answer:
The procedure is as follows:
MOV BIG, #0
MOV R0, #LIST
MOV R2, #30
CHA:
MOV A, @R0
CJNE A, BIG, QQQ
QQQ:
JC WWW
MOV BIG, A
WWW:
INC R0
DJNZ R2, CHA
SJMP $
END
;End
;--------------------------------------------------------------------------------
=================================================================
Another question:
Microcontroller programming question is urgent!!! Experts please come in, I will give you points!!!
Reward points: 20 | Solved time: 2010-4-11 21:41 |
1. Program the high 4 bits in the external data memory 2100H unit to be "1", and the rest of the bits to be "0"
2. Program the 0th and 7th bits in the internal data memory 40H unit to be "1", and the rest of the bits to be inverted.
Add comments, thank you
;----------------------------------------------------------------
Best answer:
1. Program the high 4 bits in the external data memory 2100H unit to "1" and the rest to "0"
MOV DPTR, #2100H ; set address
MOV A, #11110000B ; prepare digital
MOVX @DPTR, A ; send to external data memory 2100H unit
2. Program the 0th and 7th bits of the internal data memory 40H unit to "1" and invert the remaining bits.
MOV A, 40H
ORL A, #10000001B ; or, that is, adding according to the "bit"
XRL A, #01111110B ; using 1 XOR, equivalent to taking the inverse
MOV 40H, A
;----------------------------------------------------------------
Postscript:
The logic operation instructions of the 51 single-chip microcomputer can be directly performed on the RAM address on the chip.
Using this method, only two instructions are needed:
ORL 40H, #10000001B; or, that is, adding according to the "bit"
XRL 40H, #01111110B; using 1 XOR, which is equivalent to AND negation
. This method is too simple!
However, if it is for homework, I am afraid it will not work, because teachers all hope to solve it with stupid methods.
Previous article:Design a pulse generator with adjustable pulse width and duty cycle of 50% and 25%
Next article:MCU Programming: Find the average value of 8 unsigned numbers
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
- [2022 Digi-Key Innovation Design Competition] I am just an image porter
- Nengdian Electronics Capacitive Liquid Level Sensor D1CS-D54 Review
- [Zhongke Bluexun AB32VG1 RISC-V board "meets" RTT] GPIO simulation realizes full-color LED lights
- Solution | Application of Feiling FETMX8MP-C core board in AGV car
- What will happen if you connect the input and output of the power bank?
- [Silicon Labs Development Kit Review] TensorFlow Application Code Analysis Based on Deep Learning
- Direction of electrical energy transfer in a circuit
- Detailed explanation of the BQ25618/9 dedicated switch charging chip for TWS true wireless headset charging compartment
- TI DLP high-performance system for spectral analysis of liquids and solids
- AD package library