JMP A1
ORG 002BH
A1: MOV R0,#00001001B; dividend
MOV R1,#0; remainder
MOV R2,#0;
quotient MOV R5,#00000011B; divisor
MOV 33H,#8; left shift 8 times 16-bit division left shift 16 times
A2: MOV A,R0
RLC A
MOV R0,A
MOV A,R1
RLC A
MOV R1,A
SUBB A, R5; Subtract the quotient from the shifted number
JC A3; Compare the size
MOV R1, A; If it is larger, save the remainder and subtract
A3 next time: CPL C; Quotient value processing
MOV A, R2; Quotient value shift
RLC A
MOV R2, A
DJNZ 33H, A2; Is it completed
JMP $
; Idea---As long as R1-R5 is not less than 0, the quotient is set to 1 and the remainder is assigned to R1
; R1 R5 R2
; 1. 00000000-00000011 is less than 0, and the quotient is 00000000
; 2. 00000000-00000011 is less than 0, and the quotient is 00000000
; 3. 00000000-00000011 is less than 0, and the quotient is 00000000
;4. 00000000-00000011 is less than 0, and the quotient is 00000000;
5. 00000001-00000011 is less than 0, and the quotient is 00000000
; 6. 00000010-00000011 is less than 0, and the quotient is 00000000
; 7. 00000100-00000011 is greater than 0, the quotient is 00000001, and the remainder is 00000001, which is assigned to R1
; 8. 00000011-00000011 is equal to 0, the quotient is 00000011, and the remainder is 00000000
; The algorithm is now complete
; Note: Single byte is cycled 8 times, if it is double byte, it will be cycled 16 times, and so on
end
Previous article:CAN network characteristic impedance and terminal impedance
Next article:Divide a 4-digit hexadecimal number by a 4-digit hexadecimal number using shift and subtraction
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
- Detailed explanation of Zigbee networking principle
- National Undergraduate Electronic Design Competition Commonly Used Modules and Related Devices Data Album
- TOP223 chip
- Effects of Improper Use of Derived Clocks on Logic Timing
- Consulting on segment LCD issues
- Oscilloscope measurement of automotive LIN bus signal and waveform analysis
- Southchip SC8905 evaluation board free evaluation, supports charging and discharging bidirectional operation
- Analysis of the design steps of RS-485 bus interface circuit
-
[NXP Rapid IoT Review] +
NXP Rapid IoT Online IDE Air Quality Test - How to remotely control a two-wheeled balancing vehicle via the Internet?