This program calculates the square root of an unsigned 32-bit number with some bit fiddling to get a very close approximation, then one iteration of the Babylonian method to get an exact value. I don't know if this could be faster, but hope it can.I have trouble with clearly commenting my code, so I will gladly explain unclear portions of code.[global sqrti]sqrti:        mov     eax, [esp+4]        xor     ecx, ecx       ; clear register to put our approximation in        ; make the lower 16 bits of CX equal the even-numbered bits of EAX        shr     eax, 3        rcr     cx, 1%rep 14        shr     eax, 2        rcr     cx, 1%endrep        ; do one iteration of the Babylonian method        or      ecx, 1          ; prevent a division by zero        mov     eax, [esp+4]        xor     edx, edx        ; clear top half of DIV's implied operand        div     ecx        add     eax, ecx        shr     eax, 1        ret
Integer square root in x86 assembly (NASM)
algorithm;beginner;mathematics;assembly;bitwise