Statement:Write a program to find the Square Root of an 8 bit binary number. The binary number is stored in memory location 4200H and store the square root in 4201H.
Home
8085 Forum
8085 Free Projects
8085 Free Programs
8085 Tutorials
8085 details
Interfacing Techniques
Electronic Tutorials
Electronic Projects
Assembler/ IDE
Datasheets
Guest Book
About Me
Source Program:

               LDA 4200H                : Get the given data(Y) in A register
               MOV B,A                : Save the data in B register
               MVI C,02H                : Call the divisor(02H) in C register
               CALL DIV                : Call division subroutine to get initial value(X) in D-reg
       REP: MOV E,D                : Save the initial value in E-reg
               MOV A,B                : Get the dividend(Y) in A-reg
               MOV C,D                : Get the divisor(X) in C-reg
               CALL DIV                : Call division subroutine to get initial value(Y/X) in D-reg
               MOV A, D                : Move Y/X in A-reg
               ADD E                        : Get the((Y/X) + X) in A-reg
               MVI C, 02H                : Get the divisor(02H) in C-reg
               CALL DIV                : Call division subroutine to get ((Y/X) + X)/2 in D-reg.This is XNEW
               MOV A, E                : Get Xin A-reg
               CMP D                        : Compare X and XNEW
               JNZ REP                : If XNEW is not equal to X, then repeat
               STA 4201H                : Save the square root in memory
               HLT                        : Terminate program execution


Subroutine:

       DIV: MVI D, 00H                : Clear D-reg for Quotient
       NEXT:SUB C                        : Subtact the divisor from dividend
               INR D                        : Increment the quotient
               CMP C                        : Repeat subtraction until the
               JNC NEXT                : divisor is less than dividend                
               RET                        : Return to main program


FLOWCHART




Flowchart for Source Program:
Flowchart for subroutine:

Note: The square root can be taken y an iterative technique. First, an initial value is assumed. Here, the initial value of square root is taken as half the value of given number. Te new value of square root is computed by using an expression XNEW = (X + Y/X)/2 where, X is the initial value of square root and Y is the given number. Then, XNEW is compared wit initial value. If they are not equal then the above process is repeated until X is equal to XNEW after taking XNEW as initial value. (i.e., X XNEW)