Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

An Assembly Language Program to find the square root of a number using 8085?

Algorithm

1) Load the HL pair with the address of the number whose square root is to be found.
2) Copy the number to accumulator.
3) Initialize E with 0.
4) Subtract content of E from accumulator.
5) Increment register E by 2.
6) Increment content C register by 1.
7) Compare accumulator content with 0.
8) If accumulator content is not zero then go to step 4 else go to step 9.
9) Store the square root in to the memory.
10) Terminate the program.

Program

MEMORY LABEL MNEMONIC HEX COMMENT


CODE
4200 MVI C,00 0E Initialize C as 0
4201 00
4202 LXI H,4100 21 Load HL pair with the address of
4203 00 the data whose occurrence is to be
4204 41 found
4205 MOV A,M 7E Copy the data to the Accumulator
4206 MVI E,01 1E Initialize E with 0
4207 01
4208 LOOP SUB E 93 [A] [A] + [E]
4209 INR E 1C Increment register E
420A INR E 1C Increment register E
420B INR C 0C Increment register C
420C CPI ,00 FE Compare accumulator content
420D 00 with 0
420E JNZ LOOP C2 Jump on non-zero to the label
420F 07 LOOP
4210 42
4211 MOV A,C 79 Copy content of register C to
accumulator
4212 STA 4500 32
4213 00 Store the square root in 4500
4214 45
4215 HLT 76 Program ends

Observation

Input at 4100 : 31H


Output at 4500 : 07H ------------ Square root

You might also like