• Advertisement

Archived

This topic is now archived and is closed to further replies.

sin/cos in ASM

This topic is 6011 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi! I have a probelem with some ASM functions I found on the net. When I try to use them it gives me a error like : Unhandled exception at 0x0012fc62 in FrameWork.exe: 0xC0000005: Access violation reading location 0xcccccccc. Any ideas why... and how do I fix this the code looks like this (I hope cpp tags work )) // Asm version of sinf() __forceinline float __fastcall FastSin(float a) { __asm { fld DWORD PTR [esp+4] fsin ret 4 } } // Asm version of cosf() __forceinline float __fastcall FastCos(float a) { __asm { fld DWORD PTR [esp+4] fcos ret 4 } } There are more worlds than the one that you hold in your hand...

Share this post


Link to post
Share on other sites
Advertisement
likw what?

if I only write something like

float x = FastSin(3.14f);

it gives me this error?

could someone please try it in your code and tell me if it works for them.

ps. I''m using MSVS7 (.NET)

There are more worlds than the one that you hold in your hand...

Share this post


Link to post
Share on other sites
Well, if I understand things correctly you are loading [esp+4] into st0, under the assumption that [esp+4] contains the float-parameter 'a'. The problem is probably that with the __fastcall calling convention the compiler may pass some of the parameters to a function in registers. Try replacing the __fastcall with __stdcall.

I may be completely wrong here, regarding what the code is supposed to do, I've never actually used x87 instructions myself

Edited by - Dactylos on September 8, 2001 7:15:15 AM

Share this post


Link to post
Share on other sites

  • Advertisement