flat assembler
Message board for the users of flat assembler.

Index > Heap > []

Author
Thread Post new topic Reply to topic
Spool



Joined: 08 Jan 2013
Posts: 154
Spool
[ Post removed by author. ]


Last edited by Spool on 17 Mar 2013, 10:06; edited 3 times in total
Post 30 Jan 2013, 04:19
View user's profile Send private message Reply with quote
Xorpd!



Joined: 21 Dec 2006
Posts: 161
Xorpd!
Since tanθ=sinθ/√(1-sin²θ), we can see that ASIN(x) = ATAN(x/√(1-x²)), so ACOS(x)=π/2-ATAN(x/√(1-x²)). The x87 FPU has an FPATAN instruction that helps with this. Even better, FPATAN works like the ATAN2 function in case you are trying to convert from rectangular to polar coordinates.
Post 30 Jan 2013, 05:30
View user's profile Send private message Visit poster's website Reply with quote
Spool



Joined: 08 Jan 2013
Posts: 154
Spool
[ Post removed by author. ]


Last edited by Spool on 17 Mar 2013, 10:05; edited 1 time in total
Post 30 Jan 2013, 05:42
View user's profile Send private message Reply with quote
Xorpd!



Joined: 21 Dec 2006
Posts: 161
Xorpd!
Sorry, I was thinking only in terms of ATAN(x) rather than ATAN2(y,x) which is what FPATAN gives you. Thus ASIN(x) = ATAN2(x,√(1-x²)) and ACOS(x) = ATAN2(√(1-x²),x), both correct even when x ≤ 0. This saves you an FSUBR compared with the recommendation of my previous post.
Post 30 Jan 2013, 16:53
View user's profile Send private message Visit poster's website Reply with quote
Walter



Joined: 26 Jan 2013
Posts: 143
Walter
Other reference:

Raymond's FPU Library

http://www.ray.masmcode.com/fpu.html


Or the C runtime

Code:
format pe console

entry start

include 'win32ax.inc'

.data

    fValue  dq 0.5

.code

start:

    cinvoke acos,double[fValue]
    fstp    qword[fValue]
    cinvoke printf,<"%f",13,10,0>,double[fValue]
    invoke  ExitProcess,0

data import

  library kernel32,'kernel32.dll',\
          msvcrt,'msvcrt.dll'

  import kernel32,\ 
         ExitProcess,'ExitProcess' 

  import msvcrt,\
         acos,'acos',\
         printf,'printf'

end data                                 
    
Post 30 Jan 2013, 18:14
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.