mmicroprocessor.blogspot.com
.MODEL SMALL
.DATA ; Data
segment starts
NUM1 DB 19H ;
Initialize num1 to 0019
SQRT DB 01 DUP (?)
; Reserve 1 word of uninitialised data space to offset sqrt
.CODE ; Code
segment starts
.STARTUP
MOV AL,NUM1 ;Move
the number(num1) to AL
XOR BL,BL ;XOR is
performed and result is stored in BL
MOV BL,01H ;Initialize
BL to 01H
MOV CL,01H
;Initialize CL to 01H
LOOP1: SUB AL,BL
;AL=AL-BL
JZ LOOP2 ; If zero
flag is zero jump to loop2
INC CL ; Increment
CL by 1
ADD BL,02H
;BL=BL+02H
JMP LOOP1 ; Jump
to loop1
LOOP2: MOV SQRT,CL
; Store result
MOV DL,CL
ADD DL,30H
CMP DL,'9'
JBE L1
ADD DL,7H
L1:
MOV AH,02H
INT 21H
MOV AH,4CH
INT 21H
END
Output:
5
.MODEL SMALL
ReplyDelete.STACK 100
.DATA
M1 DW 0004H
M2 DB 0AH,0DH,"NO ROOT"
.CODE
START:MOV AX,@DATA
MOV DS,AX
MOV SI,OFFSET M1
MOV DX,[SI]
CMP DX,0001H
JZ EXIT1
MOV AX,DX
MOV CL,0002H
DIV CL
MOV BL,AL
MOV BH,00H
MOV CX,0001H
L1:MOV AH,CL
MOV AL,CL
MUL AH
CMP AX,DX
JZ SKIP
CMP CX,BX
JNC EXIT1
INC CX
JMP L1
EXIT1:LEA DX,M2
MOV AH,09H
INT 21H
JMP L2
SKIP:MOV DX,CX
ADD DX,0030H
MOV AH,02H
INT 21H
L2:NOP
.EXIT
END START
.MODEL SMALL
ReplyDelete.STACK 100
.DATA
M1 DW 0004H
M2 DB 0AH,0DH,"NO ROOT"
.CODE
START:MOV AX,@DATA
MOV DS,AX
MOV SI,OFFSET M1
MOV DX,[SI]
CMP DX,0001H
JZ EXIT1
MOV AX,DX
MOV CL,0002H
DIV CL
MOV BL,AL
MOV BH,00H
MOV CX,0001H
L1:MOV AH,CL
MOV AL,CL
MUL AH
CMP AX,DX
JZ SKIP
CMP CX,BX
JNC EXIT1
INC CX
JMP L1
EXIT1:LEA DX,M2
MOV AH,09H
INT 21H
JMP L2
SKIP:MOV DX,CX
ADD DX,0030H
MOV AH,02H
INT 21H
L2:NOP
.EXIT
END START
HOW TO INPUT AND EXECUTE OUTPUT. I WANT TO ENTER USER DEFINED VALUES
ReplyDelete