Its disneat because im not arranged yet. I place it here as a backup and for you to share. You are allowed to modify or do anything for commercial purpose or not.
Attachments:
Posted on 2005-06-20 07:56:41 by realvampire
Here is the latest example. But the source is above 256 Kbytes I cannot give it to you rigth now.


Here is the very basic function to made a circle. Unfortunately FPU is very slow. Im still find another way to make it fast and this is what I know to make it fast.

*Note: The clock information on this code is wrong*

If this code

push eax
fld dword ptr
pop eax
fimul delta
fistp r_cos

replaced with this code

; xor edx,edx
; mov ecx,delta
; mul ecx
; mov ecx,1000
; div ecx
; mov eax,r_cos

I can save time until 15 times on 1.7 GHz celeron machine. I tried it but it crashed. I dont know what causing it. When I debug it with ollydbg, it stop at this function.


GetSin proc uses esi deg:dword ; 3 Clock cycle

mov esi,SCTbl ; 1 Clock cycle
mov ecx,deg ; 1 Clock cycle
mov eax,dword ptr ; 1 Clock cycle

ret
GetSin endp


Ecx register on GetSin procedure point to a wrong place and reported access violation. Maybe someone here understand and can solve this?


Phase1 proc uses esi ; 28.8 Kbyte needed
LOCAL deg,sin,cos,tan:dword


invoke GlobalAlloc,LMEM_DISCARDABLE,28800+14400 + 16*10000 +768
invoke GlobalLock,eax
mov SCTbl,eax


mov esi,eax ; 1 Clock cycle
xor ecx,ecx ; 1 Clock cycle
mov deg,ecx ; 1 Clock cycle

mov edx,3600 ; 1 Clock cycle
shl edx,2 ; 2 Clock cycle


@@:
finit ; 17 Clock cycle
pushad
invoke Deg2Rad,deg ; 104 Clock cycle
popad
fsincos ; 365 Clock cycle
fstp sin ; 8 Clock cycle
fstp cos ; 8 Clock cycle

; push 1000
; fimul dword ptr
; fistp sin
; pop eax
; push 1000
; fimul dword ptr
; fistp cos
; pop eax

mov eax,sin ; 1 Clock cycle
mov dword ptr,eax ; 1 Clock cycle
mov eax,cos ; 1 Clock cycle
mov dword ptr,eax ; 1 Clock cycle

add deg,1 ; 3 Clock cycle
add esi,4 ; 1 Clock cycle
add ecx,4 ; 1 Clock cycle
cmp deg,3600 ; 2 Clock cycle
jl @b ; 3 Clock cycle
; 513 Clock cycle Each loop
; 1846800 Clock cycle total loop
; 1846806 Clock cycle
mov esi,SCTbl
add esi,28800
;Tan
mov edx,3600 ; 1 Clock cycle
shl edx,2 ; 2 Clock cycle

xor ecx,ecx
mov deg,ecx

@@:
finit ; 17 Clock cycle
pushad
invoke Deg2Rad,deg ; 104 Clock cycle
popad
fptan ; 273 Clock cycle
fstp tan
; push 1000
; fimul dword ptr
; fistp tan
; pop eax
;
push tan
pop
add deg,1 ; 3 Clock cycle
add esi,4 ; 1 Clock cycle
add ecx,4 ; 1 Clock cycle
cmp deg,3600 ; 2 Clock cycle
jl @b ; 3 Clock cycle


mov esi,SCTbl
add esi,28800+14400
mov Line_Table,esi
mov eax,16*10000
mov nLLimit,eax
mov nLPtr,0

add esi,eax
mov SCR_TBL,esi

mov ecx,768
xor eax,eax
xor edx,edx
@@:
mov ,eax
add eax,1024
dec ecx
jnz @b

ret
Phase1 endp


UMGetPosRound proc uses esi delta:dword,deg:dword ; 138 Clock cycle
LOCAL r_sin,r_cos:dword


cmp deg,3600
jl @f
sub deg,3600
@@:
invoke GetSin,deg
push eax
fld dword ptr
pop eax
fimul delta
fistp r_sin

; xor edx,edx
; mov ecx,delta
; mul ecx
; mov ecx,1000
; div ecx
; mov eax,r_sin

invoke GetCos,deg
push eax
fld dword ptr
pop eax
fimul delta
fistp r_cos

; xor edx,edx
; mov ecx,delta
; mul ecx
; mov ecx,1000
; div ecx
; mov eax,r_cos

mov edx,r_sin
mov eax,r_cos


ret
UMGetPosRound endp

GetSin proc uses esi deg:dword ; 3 Clock cycle

mov esi,SCTbl ; 1 Clock cycle
mov ecx,deg ; 1 Clock cycle
mov eax,dword ptr ; 1 Clock cycle

ret
GetSin endp

GetCos proc uses esi deg:dword ; 4 Clock cycle

mov esi,SCTbl ; 1 Clock cycle
add esi,14400 ; 1 Clock cycle
mov ecx,deg ; 1 Clock cycle
mov eax,dword ptr ; 1 Clock cycle

ret
GetCos endp

GetTan proc uses esi deg:dword ; 4 Clock cycle

mov esi,SCTbl ; 1 Clock cycle
add esi,28800 ; 1 Clock cycle
mov ecx,deg ; 1 Clock cycle
mov eax,dword ptr ; 1 Clock cycle

ret
GetTan endp


Attachments:
Posted on 2005-06-20 08:00:04 by realvampire