;Adobe Helvetica normal ;------------------------------------------------- ;Errechnet die gerundete Wurzel eines 64Bit Integerwertes ;------------------------------------------------- ;The result is a rounded squareroot of a 64-Bit integer value ;------------------------------------------------- ; Code for the best assembler: The Netwide Assembler: NASM ; Copyright (C) 2004 by Sebastian Beck; sebastian.bw@freenet.de ; Wenn Sie eine Spende machen wollen, fragen Sie mich über E-Mail ; nach meiner Bankverbindung. ; If you want to make a donation, please question me by e-mail for ; my banking connection. ; This program is free software; you can redistribute it and/or modify ; it under the terms of the GNU General Public License as ; published by the Free Software Foundation. ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; GNU General Public License for more details. ; http://www.gnu.org/ ;------------------------------------------------- ;%include "./INC/sqrt64.inc" ;To your global or the declaration of the calling process. ;Wert dd 0,0 ;value -unchanged ;Ergebnis dd 0,0 ;result ;------------------------------------------------- sqrt64: section .text pushad bsr ecx,[Wert+4] jnz .a2 mov ecx,0 jmp .a4 .a2: add ecx,32 jmp .a8 .a4: bsr ecx,[Wert] jnz .a8 mov dword[Ergebnis],0 jmp .ende .a8: shr ecx,1 ;geteilt durch 2 mov ebx,0 bts ebx,ecx .b4 cmp ecx,0 je .c2 dec ecx bts ebx,ecx mov edx,0 mov eax,ebx mul ebx cmp edx,[Wert+4] je .b6 jb .b4 .b5: btr ebx,ecx jmp .b4 .b6: cmp eax,[Wert] jb .b4 jz .c2 jmp .b5 .c2 mov edx,0 mov eax,ebx inc eax jc .c8 mul ebx cmp edx,[Wert+4] je .c4 jb .c6 mov [Ergebnis],ebx jmp .ende .c4: cmp eax,[Wert] jb .c6 mov [Ergebnis],ebx jmp .ende .c6: inc ebx .c8: mov [Ergebnis],ebx .ende: popad ret