Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Selected Reading
8085 program to find square of a 8 bit number
In this program, we will see how to find the square of an 8-bit number.
Problem Statement
Write 8085 Assembly language program to find the square of a number The number is stored at location 8000H, store the result at 8050H.
Discussion
In 8085, we cannot perform the multiplication operation directly. We are performing the multiplication by using repetitive addition. To get square of a number, we have to multiply the number with itself.
Input
|
Address |
Data |
|---|---|
| … |
… |
|
8000 |
0C |
| … |
… |
Flow Diagram

Program
|
Address |
HEX Codes |
Labels |
Mnemonics |
Comments |
|---|---|---|---|---|
|
F000 |
21, 00, 80 |
|
LXI H,8000H |
Load the number from 8000H |
|
F003 |
AF |
|
XRA A |
Clear accumulator |
|
F004 |
46 |
|
MOV B,M |
Load data from memory to B |
|
F005 |
86 |
LOOP |
ADD M |
Add memory byte with A |
|
F006 |
05 |
|
DCR B |
Decrease B by 1 |
|
F007 |
C2, 05, F0 |
|
JNZ LOOP |
If Z = 0, jump to loop |
|
F00A |
32, 50, 80 |
|
STA 8050H |
Store result into memory |
|
F00D |
76 |
|
HLT |
Terminate the program |
Output
|
Address |
Data |
|---|---|
| … |
… |
|
8050 |
90 |
| … |
… |
Advertisements
