I. Usage
1. Find the integer of the quotient
(1) The hexadecimal dividend is sent to the 20 (low) to 23 (high) units in the 51 internal RAM, and the divisor is sent to the 50 (low) to 53 (high) units. The expansion units 24 to 27 are cleared. '
(2) Call the subroutine DIV.
(3) The 20 (low) to 23 (quotient position) units are the quotient to be found, and the 24 to 27 units are the remainder.
2. Find the 8-byte quotient
(1) First find the integer part of the quotient
The method is the same as above, and then the integer quotient of units 20 to 23 is sent to other units for storage.
(2) Find the decimal part of the quotient
. Clear cells 20 to 23; the contents of the other cells remain unchanged; call the DIV subroutine; the decimal quotient is in cells 23 to 20, and the decimal point is
before cell 23.
3. Find the reciprocal
(1) Clear cells 20 to 23 and cells 25 to 27, send 01H to cell 24, and send the divisor to cells 50 (lower order) to 53 (higher order).
(2) Call the DIV subroutine.
(3) The reciprocal is in cells 23 to 20, and the decimal point is before cell 23.
2. Program List
ORG 0500H
DIV: CLR 7EH
MOV R0,#50H
MOV R7,#03H
DV0: MOV A,@R0
INC R0
ORL A,@R0
JNZ DV1
DJNZ R7,DV0
SETB 7EH
SJMP DV8
DV1: MOV R6,#20H
CLRC
DV2: MOV R0,#20H
MOV R7,#08H
DV3: MOV A,@R0
RLC A
MOV @R0,A
INC R0
DJNZ R7,DV3
MOV 0F0H,C
CLR C
MOV R0,#24H
MOV R1,#50H
MOV R7,#04H
DV4: MOV A,@R0
SUB A,@R1
MOV @R0,A
INC R0
INC Rl
DJNZ R7,DV4
JNB 0F0H,DV5
CLR C
SJMP DV6
DV5: JNC DV6
MOV A,24H
ADD A,50H
MOV 24H,A
MOV A,25H
ADDC A,51H
MOV 25H,A
MOV A,26H
ADDC A,52H
MOV 26H,A
MOV A,27H
ADDC A,53H
MOV 27H,A
DV6: CPL C
DJNZ R6,DV2
MOV R0,#20H
MOV R7,#04H
DV7: MOV A,@R0
RLC A
MOV @R0,A
INC R0
DJNZ R7,DV7
DV8: RET
END
Previous article:51 single chip microcomputer keyboard interface circuit (including source code)
Next article:at89c51 electronic clock circuit diagram and program
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
- Definition of Direct Current and Alternating Current
- [Reference Book] PCB Design Tips (ADI Think Tank)
- Share: How to reduce EMI and shrink power supply size with integrated active EMI filters
- Calculation and setting of baud rate of msp430 microcontroller
- What is this device and what does it do?
- NeoPixel NanoRing
- How to optimize the area of FPGA design
- LED screen blanking technology
- Integer division problem
- MSP430F5529LP (I) HELLOWRLD of IIC and OLED