Seeing this topic, haha, many people may want to hit Shitou brother with the board; what is 7+5? Do I need you to teach me this? But in the single-chip microcomputer, numbers are represented by binary: this is a bit difficult to understand/ Although our textbook has reached this point, you may not have learned a single instruction. But what I mean is to do a few experiments first to increase everyone's interest in single-chip microcomputers. There are too many specific instructions, but fortunately, generally we only need to remember 10-20 commonly used ones. OK, now start.
We write the following two instructions
MOV P1,#23H
END
I think everyone can understand this program. It sends the hexadecimal number 23H to the P1 port (i.e. P1.0--P1.7), compiles the HEX code and burns it, then inserts the chip into the experimental card holder; you can see that the status of P1.0-1.7 is;
P1.0 Off
P1.1 off
P1.2 Bright
P1.3 Bright
P1.4 Bright
P1.5 off
P1.6 Bright
P1.7 Bright
(Photo of Yitian Development Kit in action)
Why is this happening?
Note that because the 8 lights of our P1 port are connected to positive 5V at one end and the port at the other end, the port is low level 0. The LED is on. High level is not on. Arranged from high to low (from 1.7 to 1.0), it is 00100011. This number is 23H. What? You don't believe it? Well, please continue reading! 00100011 is 100011 in binary. According to the principle of mathematics, the leading 0 does not count.
Follow me to open the computer's Programs/Accessories/Calculator, and then set the calculator to scientific type. Then click Binary and enter 100011
Then click on the hexadecimal number and you can see that the number becomes 23. This is the 23H we entered.
Exercise: 25H+36H?
The procedure is as follows:
MOV R0,#25H; Send the immediate value 25 to register R0
MOV A,#36H; Send the immediate value 36 to accumulator A
ADD A,R0; add the contents of R0 and A, and the result is in A
NOP; no operation
POV P1,A; send the value of accumulator A to port P1.
END; End
After compiling the program, burn it into the chip and run it; you can see that the status of the light is
P1.0 Off
P1.1 off
P1.2 Bright
P1.3 Extinction
P1.4 Extinction
P1.5 Bright
P1.6 Extinction
P1.7 Bright
That is the binary number 01011011. Let's use the calculator above to see if the result is correct: first set the calculator to hexadecimal, enter 25+36 = the result is 5E
Then click on the binary result, which is 1011110. It can be seen that the result is completely correct.
You can then practice on your own
Subtraction instruction SUBB
Multiplication instruction MUL
Division instruction DIV
I believe that after learning this section, everyone will have a deep impression of these instructions. At the same time, it also gives us a better understanding of computer numbers.
Deep understanding.
Previous article:The fourth experiment: the small speaker makes the sound of an ambulance
Next article:Experiment 7--------Comprehensive exercise on digital display of running lights
- 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!
- Rambus Launches Industry's First HBM 4 Controller IP: What Are the Technical Details Behind It?
- 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
- 485 Communication abnormality
- What is the difference between hot ground and cold ground in a power supply?
- EEWORLD University Hall----Live playback: Deeply explore the new generation of CapTIvate? touch technology with integrated host controller functions
- EEWORLD University ---- Programming Methods
- Will controlling the LED in this way cause current bias?
- Excuse me, what are the main parameters of the motor and reduction mechanism used in the water meter switch valve?
- [2022 Digi-Key Innovation Design Competition] Electronic photo frame based on STM32H745
- Prize-winning live broadcast | Registration for the application of Weidmuller products in the semiconductor industry has begun!
- STM32MP157A-DK1 Review - 4. Cortex-M4 in Heterogeneous Multiprocessing MPU
- I designed the stm32f429 core board and LCD screen myself, and I would like to share it with you