- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

In this program we will see how to find nth power of a number.

Write 8085 Assembly language program to find nth power of a number. The base is stored at location 8000H, and the exponent is stored at 8001H. Store the result at 8002H.

In 8085, we cannot perform the multiplication operation directly. Here we are writing a subroutine to perform the multiplication by using repetitive addition. To perform nth power of a number, we have to multiply the number n times. The n value is used as a counter. If the base is 03H, exponent is 05H, then the result is F3H (243D)

Address | Data |
---|---|

… | … |

8000 | 03 |

8001 | 05 |

Address | HEX Codes | Labels | Mnemonics | Comments |
---|---|---|---|---|

F000 | 21, 00, 80 | | LXI H,8000H | Initialize HL pair |

F003 | 46 | | MOV B,M | Take Base to B |

F004 | 23 | | INX H | Point to next location |

F005 | 4E | | MOV C,M | Take exponent to C |

F006 | 16, 01 | | MVI D, 01H | Initialize D with 01H |

F008 | CD, 12, F0 | LOOP | CALL MUL | Call the subroutine to multiply |

F00B | 0D | | DCR C | Decrease C by 1 |

F00C | C2, 08, F0 | | JNZ LOOP | Jump to Loop |

F00F | 23 | | INX H | Point to next location |

F010 | 72 | | MOV M,D | Store D into memory |

F011 | 76 | | HLT | Terminate the program |

F012 | 58 | MUL | MOV E,B | Load B to E |

F013 | AF | | XRA A | Clear accumulator to store result |

F014 | 82 | ML | ADD D | Add D to A |

F015 | 1D | | DCR E | Decrement E |

F016 | C2, 12, F0 | | JNZ ML | If Z = 0, jump to ML |

F019 | 57 | | MOV D,A | Transfer contents of A to D |

F01A | C9 | | RET | Return result |

Address | Data |
---|---|

8002 | F3 |

- Related Questions & Answers
- 8085 program to find square root of a number
- 8085 program to find the factorial of a number
- 8085 program to find square of a 8 bit number
- Program to find Nth Fibonacci Number in Python
- Program to find nth ugly number in C++
- C++ Program to Calculate Power of a Number
- C++ Program to find whether a number is the power of two?
- How to find power of a number in Python?
- 8085 Program to find the smallest number
- Java program to calculate the power of a number
- C program to calculate power of a given number
- 8085 Program to find Square of a number using look up table
- 8085 program to find sum of digits of 8 bit number
- Program to find last two digits of Nth Fibonacci number in C++
- Find power of a number using recursion in C#

Advertisements