When i try to write Heron algorithm to count sqrt from ECX register, it doesn't work. It looks like the problem is dividing floating numbers, because the result is integer.
My algorithm:
sqrtecx:
MOV EDX, 10 ; loop count
MOV EAX, 5 ; x_0 in heron algorythm
MOV DWORD[EBP-100], ECX ; save INPUT (ecx is input)
MOV DWORD[EBP-104], EDX ; save loop count
jmp loop
MOV ECX, EAX ; move OUTPUT to ECX
loop:
MOV DWORD[EBP-104], EDX ; save loop count
xor edx, edx
MOV ECX, EAX
MOV EAX, DWORD[EBP-100]
DIV ECX
ADD EAX, ECX
XOR EDX, EDX
mov ecx, 2
DIV ecx
MOV EDX, DWORD[EBP-104] ; load loop count
DEC EDX
JNZ loop
DIV
is for integer division - you needFDIV
for floating point (or more likelyFIDIV
in this particular case, since it looks like you are starting with an integer value).