Example: Divide (R2R3R4R5) by (R6R7), the quotient is sent to (R4R5), and the remainder is sent to (R2R3). Manual calculation method:
1) Align the divisor from the high bit of the dividend and compare.
2) If the former is greater than or equal to the latter, the quotient is 1, and the dividend is subtracted from the divisor to form a partial remainder. If the former is less than the latter, the quotient is 0.
3) The partial remainder is shifted left by one bit, and the quotient is also shifted left by one bit.
4) If the entire remainder is less than the divisor, exit.
5) Compare the partial remainder with the divisor from the high bit
6) Go to step 2).
If the high 16 bits of the dividend are greater than or equal to the divisor, overflow occurs.
NDIV: MOV A, R3
CLR C
SUBB A, R7 ; first compare whether overflow occurs
MOV A, R2
SUBB A, R6
JNC NDVE1 ; overflow
MOV B, #16 ; no overflow, 16 bits
NDVL1: CLR C
MOV A, R5
RLC A
MOV R5, A
MOV A, R4
RLC A
MOV R4, A ; the dividend is shifted left by one bit, and the quotient is also shifted left by one bit
MOV A, R3
RLC A
MOV R3, A
MOV A, R2
RLC A
MOV R2, A
MOV F0, C ; save the highest bit shifted out
CLR C
MOV A, R3
SUBB A, R7 ; compare the partial remainder with the divisor
MOV R1, A
MOV A, R2
SUBB A, R6
JB F0, NDVM1 ; if the last highest bit = 1, then the quotient bit = 1
JC NDVD1 ; if the partial remainder is less than the divisor, then the quotient bit = 0
NDVM1: MOV R2, A
MOV A, R1
MOV R3, A ; return subtraction result
INC R5 ; quotient = 1
NDVD1: DJNZ B, NDVL1 ; loop 16 times
CLR F0
RET
NDVE1: SETB F0 ; overflow flag
RET
Previous article:Improved bubble sorting microcontroller assembly language programming example
Next article:An example of a program to multiply two double-byte unsigned numbers in a single-chip microcomputer
Recommended ReadingLatest update time:2024-11-17 05:31
- Popular Resources
- Popular amplifiers
- Wireless Sensor Network Technology and Applications (Edited by Mou Si, Yin Hong, and Su Xing)
- Modern Electronic Technology Training Course (Edited by Yao Youfeng)
- Modern arc welding power supply and its control
- Small AC Servo Motor Control Circuit Design (by Masaru Ishijima; translated by Xue Liang and Zhu Jianjun, by Masaru Ishijima, Xue Liang, and Zhu Jianjun)
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
- [Evaluation of SGP40] + STM32CUBE + STM32G4 + UART communication test sensor
- Electric Blanket Thermostat
- 5V boost charging 8.4V boost charging IC
- MSP430F5529&LCD1602 Program
- Ultra-wideband technology: the nemesis of shadows and blind spots in wireless technology
- RF Basics - Professional Terminology
- MSP430 MCU Example 12-4X4 Matrix Keyboard Key Value Display
- BLDC back EMF is a bit weird
- EEWORLD University Hall----Boost and Buck-Boost DCDC Converters Help Wireless Charging Design
- How do I set the impedance of the differential line in ALTIUM19?