Problem – Write 8085 program to divide two 8 bit numbers.
- Start the program by loading the HL pair registers with address of memory location.
- Move the data to B Register.
- Load the second data into accumulator.
- Compare the two numbers to check carry.
- Subtract two numbers.
- Increment the value of carry.
- Check whether the repeated subtraction is over.
- Then store the results(quotient and remainder) in given memory location.
- Terminate the program.
|2000||LXI H, 2050|
|2003||MOV B, M||B<-M|
|2004||MVI C, 00||C<-00H|
|2007||MOV A, M||A<-M|
|2009||JC 2011||check for carry|
|2014||MOV A, C||A<-C|
|2018||HLT||terminate the program|
Explanation – Registers A, H, L, C, B are used for general purpose.
- LXI H, 2050 will load the HL pair register with the address 2050 of memory location.
- MOV B, M copies the content of memory into register B.
- MVI C, 00 assign 00 to C.
- INX H increment register pair HL.
- MOV A, M copies the content of memory into accumulator.
- CMP B compares the content of accumulator and register B.
- JC 2011 jump to address 2011 if carry flag is set.
- SUB B subtract the content of accumulator with register B and store the result in accumulator.
- INR C increment the register C.
- JMP 2008 control will shift to memory address 2008.
- STA 3050 stores the remainder at memory location 3050.
- MOV A, C copies the content of register into accumulator.
- STA 3051 stores the remainder at memory location 3051.
- HLT stops executing the program and halts any further execution.
- 8085 program to divide two 16 bit numbers
- 8085 program to count total even numbers in series of 10 numbers
- 8085 program to count total odd numbers in series of 10 numbers
- 8085 program to add two 16 bit numbers
- 8085 program to add 2-BCD numbers
- 8085 program to add two 8 bit numbers
- 8085 program to swap two 8-bit numbers
- 8085 program to add numbers in an array
- 8085 program to multiply two 8 bit numbers
- 8085 program to multiply two 16-bit numbers
- 8085 program to sum of two 8 bit numbers without carry
- 8085 program to find larger of two 8 bit numbers
- 8085 program to find maximum of two 8 bit numbers
- 8085 program to find the sum of first n natural numbers
- 8085 program to subtract two 8-bit numbers with or without borrow
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.