; Template for console application
         .586
         .MODEL  flat, stdcall
         OPTION CASEMAP:NONE

Include kernel32.inc
Include masm32.inc

IncludeLib kernel32.lib
IncludeLib masm32.lib

         .CONST
MsgExit  DB    "Press Enter to Exit",0AH,0DH,0

         .DATA
zap      DB    'Input value <65024:',13,10,0
string   DB    10 dup ('0')
otw      DB    13,10,'Root ='
rez      DB    16 dup (?)
root     DWORD 0

         .DATA?
inbuf    DB    100 DUP (?)

         .CODE
Start:
;Ввод
vvod:    Invoke StdOut,ADDR zap 
         Invoke StdIn,ADDR string,LengthOf string
         Invoke StripLF,ADDR string
;Преобразование         
         Invoke atol,ADDR string
         mov    DI,AX
;Вычисление sqrt(dx#ax) 
calc:    mov    BX,1
         mov    CX,0
         mov    AX,1 ; сумма
cycl:    cmp    AX,DI
         ja     preobr
         add    BX,2
         add    AX,BX
         jc     vvod
         inc    CX
         jmp    cycl
; Преобразование
preobr:  mov    word ptr root,CX
         Invoke dwtoa,root,ADDR rez 
; Вывод            
         Invoke StdOut,ADDR otw
                   
         XOR    EAX,EAX
         Invoke StdOut,ADDR MsgExit
         Invoke StdIn,ADDR inbuf,LengthOf inbuf		
	
         Invoke ExitProcess,0
         End    Start


