Skip to main content
gamedev.net
🔒 Locked

Untitled

Started by Slug Nov 4, 2004 at 2:51 PM 6 replies 950+ views
Original Post
Slug
Slug
-Asm Substraction Question 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; }
silvermace
silvermace
your code is wrong, you set x = 0 at the top of the function, so you outcome will be wrong if you call any SomeFunc(someValue)

also, you are using the wrong opcodes, you need to use the floating point assembly instructions (which also behave a little differently in regards to registers)

here is your code fixed up, and here is some free advice: don't learn assembly if you don't have to, thats why we have high level languages and expensive (or free) optimizing compilers. :)

float someFunc(float x){	float num = 2.4f;		_asm {		fld  dword ptr x		fsub dword ptr num		fstp dword ptr x	}	return x;}
-Danu
CJH
CJH
Then learn to speel.
Slug
Slug
Where not all as good as you, my friend...
I've learn english as my second language so f*ck you
if you're not satisfied.
CJH
CJH
Relax, kid. It's a self-derogatory joke.
Slug
Slug
Sorry, i overreacted...
Slug
Slug
can somebody erase this thread, it's just an typing error!
(thanx for hepl anyway!)

[Edited by - Slug on November 11, 2004 4:02:29 PM]
Dark Star
Dark Star
Heres a tip slug,

If u log in and delete your original post on this thread, it deletes the whole thread, because you cannot have replies when an original question thread no longer exists ;)

Thats wat I do when I get my answer and have some people being rude to me, or when there is contravesy and thread becomes a little out of hand. People find it irrittating when they wanna check to see if their remarks have hit you in the right place.

DarkStar
UK
---------------------------------------------You Only Live Once - Don't be afriad to take chances.

Topic Locked

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

Sign in to reply to this topic.