**Problem –** Write an assembly language program in 8085 microprocessor to find square root of a number.

**Example –**

**Assumptions –**

Number, whose square root we need to find is stored at memory location 2050 and store the final result in memory location 3050.

**Algorithm –**

- Assign 01 to register D and E
- Load the value, stored at memory location 2050 in accumulator A
- Subtract value stored at accumulator A from register D
- Check if accumulator holds 0, if true then jump to step 8
- Increment value of register D by 2
- Increment value of register E by 1
- Jump to step 3
- Move value stored at register E in A
- Store the value of A in memory location 3050

**Program –**

MEMORY ADDRESS | MNEMONICS | COMMENT |
---|---|---|

2000 | MVI D, 01 | D <- 01 |

2002 | MVI E, 01 | E <- 01 |

2004 | LDA 2050 | A <- M[2050] |

2007 | SUB D | A <- A – D |

2008 | JZ 2011 | Jump if ZF = 0 to memory location 2011 |

200B | INR D | D <- D + 1 |

200C | INR D | D <- D + 1 |

200D | INR E | E <- E + 1 |

200E | JMP 2007 | Jump to memory location 2007 |

2011 | MOV A, E | A <- E |

2012 | STA 3050 | A -> M[3050] |

2015 | HLT | END |

**Explanation –** Registers used A, D, E:

**MVI D, 01 –**initialize register D with 01**MVI E, 01 –**initialize register E with 01**LDA 2050 –**loads the content of memory location 2050 in accumulator A**SUB D –**subtract value of D from A**JZ 2011 –**make jump to memory location 2011 if zero flag is set**INR D –**increments value of register D by 1. Since it is used two times, therefore value of D is incremented by 2**INR E –**increments value of register E by 1**JMP 2007 –**make jump to memory location 2007**MOV A, E –**moves the value of register E in accumulator A**STA 3050 –**stores value of A in 3050**HLT –**stops executing the program and halts any further execution

Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.

## Recommended Posts:

- 8086 program to find the square root of a perfect square root number | Set-2
- 8085 program to find square of a 8 bit number
- 8086 program to find Square Root of a number
- 8085 program to find the factorial of a number
- 8085 program to find 1's and 2's complement of 8-bit number
- 8085 program to find 1’s and 2’s complement of 16-bit number
- 8085 program to find sum of digits of 8 bit number
- 8085 program to find nth power of a number
- 8085 program to find smallest number between two numbers
- 8085 program to find minimum value of digit in the 8 bit number
- 8085 program to convert an 8 bit number into Grey number
- 8085 program to count number of ones in the given 8-bit number
- 8085 program to convert an 8 bit BCD number into hexadecimal number
- 8085 program to find the element that appears once
- 8085 program to find maximum and minimum of 10 numbers
- 8085 program to find maximum of two 8 bit numbers
- 8085 program to find 2's complement of the contents of Flag Register
- 8085 program to find larger of two 8 bit numbers
- 8085 program to find the sum of a series
- 8085 program to find the sum of first n natural numbers

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. 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.