Jump to content
  • Advertisement

Archived

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

MindWipe

using two floats in assembly?

This topic is 5852 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

I need to be able to use two floats in assembly and I''m not exaclty sure how. I have a tutorial on it, but I really don''t know what to do. I understand there are 8 registers, stX (0-7) to use. But I don''t know how to access any of them I like it seems like it''s a stack that allways pushes a new value one level higher, but I don''t know how to pop things back. This is how I figure to make it. I want my floats to increase with a few floats I have (using inline asm)
  

//

// This is just an example showing the idea

// Where I just try to add two values in asm

// And it only shows how I uunderstand it, I could

// be completely wrong

//


float a,b;

a = 0.25f;
b = 0.43f;

__asm
{
  fldz  // ST0 = 0.0f

  fldz  // ST1 = 0.0f


  fadd a // ST0+=a

  ?????? // ST1+=b


}
  
How should I do it?

Share this post


Link to post
Share on other sites
Advertisement


float a,b, result;
a = 0.25f;
b = 0.43f;
__asm{ fld a // ST0 = a
fld b // ST0 = b, ST1 = a
fadd ST0, ST1 // Add ST0 and ST1 and store result in ST0
fst result // Store ST0 into variable "result"
}



does that help?

Share this post


Link to post
Share on other sites
Yeah, I think so. Thanks!

I''m a bit drunk now, so I won''t be trying it out. But I''ll do it tomorrow!!

Thank j00!

/MindWipe

Share this post


Link to post
Share on other sites
Jx,

actually I think it is fstp

In order to store the value AND pop it off the stack.

You need to make sure your clear out the FPU register stack before leaving the ASM block

Share this post


Link to post
Share on other sites
quote:
Original post by SteveC
Jx,

actually I think it is fstp

In order to store the value AND pop it off the stack.

You need to make sure your clear out the FPU register stack before leaving the ASM block



Very true... it is fstp

Share this post


Link to post
Share on other sites
quote:
Original post by Jx


float a,b, result;
a = 0.25f;
b = 0.43f;
__asm{ fld a // ST0 = a
fld b // ST0 = b, ST1 = a
fadd ST0, ST1 // Add ST0 and ST1 and store result in ST0
fst result // Store ST0 into variable "result"
}



does that help?


(I''m sober now ) Hmm... can''t get that fadd ST0, ST1 to work!?

/MindWipe

Share this post


Link to post
Share on other sites
Hm...

Now I''ve got another problem. How can I pop something as an interger in a 32bit register like eax, ebx from one of these STn regs?

/MindWipe

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!