50% found this document useful (2 votes)
5K views2 pages

An Assembly Language Program To Find The Square Root of A Number Using 8085

The program uses an 8085 assembly language algorithm to calculate the square root of a number stored in memory. It loads the number into the accumulator, initializes a register to 0, then subtracts the register from the accumulator and increments the register by 2 in a loop. It compares the accumulator to 0 and loops until it is not zero. Finally, it stores the square root value in memory and ends the program. The sample input of 31H is stored at 4100 and the output square root of 7H is stored at 4500, demonstrating the program works correctly.

Uploaded by

Deepak Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
50% found this document useful (2 votes)
5K views2 pages

An Assembly Language Program To Find The Square Root of A Number Using 8085

The program uses an 8085 assembly language algorithm to calculate the square root of a number stored in memory. It loads the number into the accumulator, initializes a register to 0, then subtracts the register from the accumulator and increments the register by 2 in a loop. It compares the accumulator to 0 and loops until it is not zero. Finally, it stores the square root value in memory and ends the program. The sample input of 31H is stored at 4100 and the output square root of 7H is stored at 4500, demonstrating the program works correctly.

Uploaded by

Deepak Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 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