# 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)

Data

8000
03
8001
05

## Program

HEX Codes
Labels
Mnemonics
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
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
F013
AF

XRA A
Clear accumulator to store result
F014
82
ML
F015
1D

DCR E
Decrement E
F016
C2, 12, F0

JNZ ML
F019
57

MOV D,A
Transfer contents of A to D
F01A
C9

RET
Return result