Skip to main content
GameDev.net gamedev.net
🔒 Locked

Asm Substraction Question

Started by Slug Nov 4, 2004 at 2:54 PM 7 replies 400+ views
Original Post
Slug
Slug
I just want to know why when i add the to float together, that give me the right aswser and not when i substract them? Why? float SomeFunc(float x) { x = 0; static float Num = 2.4; _asm{ mov eax, dword ptr x //move x into eax //add eax, dword ptr Num //add eax by Num(Work) sub eax, dword ptr Num //sub eax by Num(Don't Work) mov dword ptr x, eax //move eax into x } return x; }
Slug
Slug
it's the ony way?
arm
arm
Yep, unless you want to write a floating point library in assembler. :(
nmi
nmi
yes

The addition only worked by accident, because the representation of zero is 0 for both, integer and float.

Kwizatz
Kwizatz
you could write some fixed point math with integers but why would you?, and why are you passing x as an argument if you're setting it to 0 anyway?

anyway here is a clicky to the Intel Instruction Set Reference Manual, just look up the operations you need, there are explanations of what they do and how to use them.

Cheers!
Slug
Slug
This is just an example afther all...
Slug
Slug
but thanx to all

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.