Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 4

EXPERIMENT NO: 9

AIM: Write an assembly language program using 8086 to find Square root of 16 bit number. REQUIREMENTS: 8086 microprocessor programming kit, Xtalk (Assembler). THEORY: Square root of a no. can be obtained by subtracting continuous odd numbers from the no. till the result reduces less than zero. The no. of such subtractions possible is the square root of the no. PROCEDURE:
1. 2. 3. 4. 5.

Take CX as the register having odd number. Move the source address in SI in which number is stored. Take DX as the counter register. Move the content of SI to AX. Increment the index register SI twice to point the location where result is to be stored. Subtract CX from AX.

6.

7. Repeat steps 8 to 10 till result of subtraction is not less than zero. 8. Increment the counter. 9. Increment CX by 2. 10.
11.

Jump to step 6.

Store the value of DX (Square root of number) at the location pointed by SI.

FLOWCHART: START

No in AX

Initial root DX=000H

Take CX=0001H

AX=AX-CX

IS Diff >=0

Yes

NO
Store result in DX

DX=DX + 1

STOP

CX=CX + 02

PROGRAM: Segment Address starting from 0000 H


Memory Label location (offset) 1000 H 1003 H 1006 H 1008 H 1009 H 100A H 100D H 100F H 1011 H 1012 H 1015 H 1017 H 1019 H Down Above Mnemonic s MOV MOV MOV INC INC MOV SUB JB INC ADD JMP MOV INT3/HLT Operand SI,5000 H CX,0001H AX,[SI] SI SI DX,0000H AX,CX Down DX CX,02H Above [SI],DX Comments Effective Address of no. in SI Move 0001 H to register CX Move Content of SI to AX register Increment SI Increment SI Move 0000H in DX register Subtract CX from AX (AX<--AX-CX) Jump if below AX<CX Increment DX CX<--CX+2 Jump if AX-CX>=0 Move the content of DX in [SI] Stop

RESULT AND INFERENCE:

Number in [SI] or 5000 H : 0010 H Square root of given number at 5002 H: 0004 H

You might also like