flat assembler
Message board for the users of flat assembler.

 Index > Heap > []
Author
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
30 Jan 2013, 04:19
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.
30 Jan 2013, 05:30
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
30 Jan 2013, 05:42
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.
30 Jan 2013, 16:53
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
```
30 Jan 2013, 18:14
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

 Jump to: Select a forum Official----------------AssemblyPeripheria General----------------MainDOSWindowsLinuxUnixMenuetOS Specific----------------MacroinstructionsCompiler InternalsIDE DevelopmentOS ConstructionNon-x86 architecturesHigh Level LanguagesProgramming Language DesignProjects and IdeasExamples and Tutorials Other----------------FeedbackHeapTest Area

Forum Rules:
 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot vote in polls in this forumYou can attach files in this forumYou can download files in this forum