News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Flicker

Started by Farabi, June 17, 2005, 01:50:07 PM

Previous topic - Next topic

RuiLoureiro

Hi Farabi, i dont know if i am able to help you!
           Here are some topics about the case. I am trying to understand the problem itself, so

1.    sin(x + 360) = sin(x), cos(x + 360) = cos(x) , tan(x + 360) = tan(x)

2.    Here, why    «add ecx, 4     ; 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

ECX is not used between @@ and jl @B (i thk it is not used, but ...):

@@:   finit
      ...
      cmp  deg, 3600
      jl   @B
;-------------------------------------------------------
3.     mov    edx, 3600
       shl    edx, 2
could be           
       mov   edx, 14 400
;--------------------------------------------------------
4.     The proc  Phase1  create a table of functions SIN(deg), COS(deg) and
       TAN(deg) ( deg is the angle in degrees ) in this way:

SCTbl      dd  sin 0         <- Address = SCTbl             SCTblSin
           dd  sin 1
           ...
           dd  sin 3 599      ; 3 600 dwords = 14 400 bytes
           ;
           dd  cos 0                <- Address = SCTbl + 14 400   SCTblCos 
           dd  cos 1
           ...
           dd  cos 3 599
           ;
           dd  tan 0                <- Address = SCTbl + 28 800   SCTblTan
           dd  tan 1
           ...
           dd  tan 3 599
           ;
                                   <- Address = SCTbl + 43 200 

where you have
           mov   SCTbl, eax
would be
           mov   SCTblSin, eax
           add   eax, 14 400
           mov   SCTblCos, eax
           add   eax, 14 400
           mov   SCTblTan, eax
implying


GetSin proc uses esi deg:dword
mov esi, SCTblSin
mov ecx,deg
mov eax,dword ptr[esi+ecx*4]
ret
GetSin endp
;...................................................
GetCos proc uses esi deg:dword
mov esi, SCTblCos
mov ecx,deg
mov eax,dword ptr[esi+ecx*4]
ret
GetCos endp
;...............................................
GetTan proc uses esi deg:dword
mov esi, SCTblTan
mov ecx,deg
       mov eax,dword ptr[esi+ecx*4]
ret
GetTan endp

;-------------------------------------------------------------------------------
5.   If this code


push eax
fld dword ptr[esp]
pop eax
fimul delta
fistp r_cos


      is replaced with this code


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

       the var «r_cos»  is not defined . The value is not valid. The proc would be:


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
      ;
      ; Get Sin[deg] in EAX
      ; -------------------
@@:     invoke GetSin, deg
;                   calculate r_sin
xor edx,edx
mov ecx,delta
mul ecx
mov ecx,1000
div ecx
mov eax,r_sin  ; <= ERROR     => change      mov   r_sin , eax
;      push   eax                                                     ; r_sin
      ;
      ; Get Cos[deg] in EAX
      ; -------------------
           invoke GetCos, deg
      ;                                   calculate r_cos
xor edx,edx
mov ecx,delta
mul ecx
mov ecx,1000
div ecx
mov eax,r_cos     ; <= ERROR   => change      mov    r_cos, eax
      ;
      ; Return r_sin and r_cos
      ; ----------------------
;    pop  edx                       ; r_sin
mov edx, r_sin
mov eax, r_cos
ret
UMGetPosRound endp

If we use push  eax and pop  edx then we dont need mov  edx, r_sin and mov eax, r_cos.
Is this right ? That's all.
stay well
ポ    ゼ      チ

Farabi

Quote from: daydreamer on June 20, 2005, 04:56:29 PM
why not use bresenhams circlealgo instead?


Because I dont understand. IS there any of the ready to use MASM code for that?
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

Farabi

Quote
if we use push  eax and pop  edx then we dont need mov  edx, r_sin and mov eax, r_cos.
Is this right ? That's all.

Yes you are right.

Quote
mov eax,r_sin  ; <= ERROR     => change      mov   r_sin , eax
;      push   eax                                                     ; r_sin

This is right too. Im just know it this morning. I think you have understand.  :U
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

daydreamer

Quote from: Farabi on June 21, 2005, 03:24:05 AM
Quote from: daydreamer on June 20, 2005, 04:56:29 PM
why not use bresenhams circlealgo instead?


Because I dont understand. IS there any of the ready to use MASM code for that?
there is, you can just need to change it from using 16-bit registers, download the Gbook and code examples are included to understand several line algos, and circle algo, clipping algo
http://www.rbthomas.freeserve.co.uk/Downloads.html


Farabi

So is the the problem solved? Why it crash?
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

Farabi

Crash on Win98, annoying error. I cannot close it. Why it run on XP but not on Win98. I dont have Win98 here.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"