- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
8085 program to find nth power of a number
In this program we will see how to find nth power of a number.
Problem Statement
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.
Discussion
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)
Input
Address | Data |
---|---|
… | … |
8000 | 03 |
8001 | 05 |
Flow Diagram
Program
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 |
Output
Address | Data |
---|---|
8002 | F3 |
- Related Articles
- Program to find number of ways we can get a number which is sum of nth power of unique numbers in Python
- 8085 program to find the factorial of a number
- 8085 program to find square root of a number
- 8085 program to find square of a 8 bit number
- 8085 Program to find the smallest number
- Program to find Nth Fibonacci Number in Python
- Program to find nth ugly number in C++
- C++ program to find Nth Non Fibonacci Number
- 8085 Program to find Square of a number using look up table
- Program to find Nth Even Fibonacci Number in C++
- 8085 program to find sum of digits of 8 bit number
- C++ Program to find whether a number is the power of two?
- Haskell Program to find the power of a number using library function
- C++ Program to Calculate Power of a Number
- Program to find nth smallest number from a given matrix in Python

Advertisements