home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Equalizer BBS
/
equalizer-bbs-collection_2004.zip
/
equalizer-bbs-collection
/
DEMOSCENE-STUFF
/
BUDYN1.ZIP
/
FASTDIV.ZIP
/
FASTDIV.IN3
Wrap
Text File
|
1996-05-28
|
3KB
|
101 lines
;Fast Div Macro by Ozir/Hypnotize. Remember that eax&ebx are single (-128;127)
;┌───────────────────────────────────────────────────────────────────────────┐
;│ Fast Div Init │
;└───────────────────────────────────────────────────────────────────────────┘
FastDivInit: mov eax,65536*4
call _getHiMem
mov FastDivOff,eax
;first table (+)
mov ebp,FastDivOff
xor ecx,ecx
mov esi,0
FastDivY1: mov edi,0
FastDivX1: mov eax,esi
shl eax,16
cdq
cmp edi,0
je FastDivZeroM1
idiv edi
FastDivZeroM1: mov [ebp],eax
add ebp,4
inc ecx
inc edi
cmp edi,128
jne FastDivX1
mov edi,-128
FastDivXX1: mov eax,esi
shl eax,16
cdq
cmp edi,0
je FastDivZeroW1
idiv edi
FastDivZeroW1: mov [ebp],eax
add ebp,4
inc ecx
inc edi
cmp edi,0
jne FastDivXX1
inc esi
cmp esi,128
jne FastDivY1
;second table (-)
mov ebp,FastDivOff
add ebp,32768*4
xor ecx,ecx
mov esi,-128
FastDivY2: mov edi,0
FastDivX2: mov eax,esi
shl eax,16
cdq
cmp edi,0
je FastDivZeroM2
idiv edi
FastDivZeroM2: mov [ebp],eax
add ebp,4
inc ecx
inc edi
cmp edi,128
jne FastDivX2
mov edi,-128
FastDivXX2: mov eax,esi
shl eax,16
cdq
cmp edi,0
je FastDivZeroW2
idiv edi
FastDivZeroW2: mov [ebp],eax
add ebp,4
inc ecx
inc edi
cmp edi,0
jne FastDivXX2
inc esi
cmp esi,0
jne FastDivY2
ret
FastDivOff dd 0
;┌───────────────────────────────────────────────────────────────────────────┐
;│ Fast Div Macro │
;└───────────────────────────────────────────────────────────────────────────┘
; |
; in:eax,ebx | in:eax,ebx
; ---------------|--------------
; shl eax,16 | FastDiv
; cdq |
; idiv ebx |
; ---------------|--------------
; 48 cycles | 18 cycles
FastDiv macro
mov bh,al
movzx ebx,bx
shl ebx,2
add ebx,FastDivOff
mov eax,[ebx]
endm