[Vollbild] [Home]
;Adobe Helvetica normal
;-------------------------------------------------
;Errechnet die gerundete Wurzel eines 64Bit Integerwertes
;-------------------------------------------------
;The result is a rounded squareroot of a 64-Bit integer value
;-------------------------------------------------
LICENSE
;%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 |