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

ID: 190146

Problem Number: 11

Source Code:
.MODEL small

.STACK 100h

.DATA
number DW 16 ; Input number to find square root
result DW ? ; Variable to store the result

.CODE
MAIN PROC

MOV AX, @DATA ; Initialize data segment


MOV DS, AX

MOV AX, number ; Load the number into AX register

MOV CX, 0FFFFh ; Set the initial value of the iteration counter
MOV BX, AX ; Copy the value of AX to BX
MOV DX, 0 ; Clear DX register

CALCULATION:
ADD BX, AX ; BX = BX + AX
SHR BX, 1 ; BX = BX / 2

MOV AX, BX
MOV DX, 0
MUL AX

CMP AX, number


JAE RESULT

DEC CX
JNZ CALCULATION

RESULT:
MOV result, BX

MOV AH, 09h


MOV DX, OFFSET result
INT 21h

MOV AH, 4Ch


INT 21h

MAIN ENDP
END MAIN

Input:
number DW 25 ; Input number to find square root

OutPut:
result DW 5 ; Square root of 25 is 5

You might also like