• Welcome to Valhalla Legends Archive.
 

Inline asm issue in VC++ 6

Started by Yegg, April 06, 2007, 09:16 PM

Previous topic - Next topic

Joe[x86]

Quote from: ♥ on April 09, 2007, 03:25 AM
Joe, also, please, look at the MSDN page for DialogBoxParam, and check out the parameters. You're not even passing the correct parameters at the correct location. Did you say you tested that code? How did this work? The hInstance variable should be the last item pushed onto the stack, not the dialog box procedure function pointer - it seems like you have them out of order completely, because the dialog proc function pointer shouldn't be first onto the stack or last for that matter.

That's not my code. I simply commented his, said what was on the stack at the time, and what he was doing. I then went on to link the MSDN page for DialogBoxParam and say he needed to check out the parameters. :P

Quote from: MyndFyre[vL] on April 09, 2007, 02:18 AM
Quote from: Joex86] link=topic=16593.msg167739#msg167739 date=1176092182]
You can't set an WORD to null. You set it to 0. If you set it to null, literally, a chunk of your processor would disappear, because it'd be turned to null. Think about it. :)
WTF?  Null is another name for 0.  You can xor dx, dx, or xor dl, dl.  You can set any size of a value in a register or memory/stack variable to null.

Joe, really man, try to not spout false information.

L2joke. <3
Quote from: brew on April 25, 2007, 07:33 PM
that made me feel like a total idiot. this entire thing was useless.

warz

oh, well, way to restate what i said right before u n00b ^^

Joe[x86]

Oh. I didn't even read your post, btw. I replied from the first page. :P
Quote from: brew on April 25, 2007, 07:33 PM
that made me feel like a total idiot. this entire thing was useless.

iago

Quote from: MyndFyre[vL] on April 07, 2007, 02:18 AM
Or as is a really common practice:


xor eax, eax

I wouldn't recommend optimizing assembly unless there's a really good reason to do so.

mov eax, 0

is the best way to do it. When you start adding your own optimizations, your code becomes less readable.

If you're trying to write optimized assembly, it's generally better to just write C and ask your compiler to optimize, it'll do a better job than you ever would anyways.
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


warz

i don't feel like xor eax, eax and mov eax, 0 are too different, as far as code recognition goes. it's not tough to see both, and recognize what both are doing.

Warrior

I agree with warz(?), everytime I see xor eax, eax I usually think zero.
Quote from: effect on March 09, 2006, 11:52 PM
Islam is a steaming pile of fucking dog shit. Everything about it is flawed, anybody who believes in it is a terrorist, if you disagree with me, then im sorry your wrong.

Quote from: Rule on May 07, 2006, 01:30 PM
Why don't you stop being American and start acting like a decent human?

iago

Quote from: Dr. ♥ on April 22, 2007, 01:30 AM
i don't feel like xor eax, eax and mov eax, 0 are too different, as far as code recognition goes. it's not tough to see both, and recognize what both are doing.
That's true, because you're accustomed to it. But that's not necessarily true for everybody (like the guy in this thread), and I definitely wouldn't recommend that somebody does it.
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


Newby

Well if he knew bitwise operations well he would know xoring a number by itself results in 0. And it gets stuck on one of the two registers... both are eax... real hard choice to pick... :P
- Newby

Quote[17:32:45] * xar sets mode: -oooooooooo algorithm ban chris cipher newby stdio TehUser tnarongi|away vursed warz
[17:32:54] * xar sets mode: +o newby
[17:32:58] <xar> new rule
[17:33:02] <xar> me and newby rule all

Quote<TehUser> Man, I can't get Xorg to work properly.  This sucks.
<torque> you should probably kill yourself
<TehUser> I think I will.  Thanks, torque.

Joe[x86]

Now, am I an idiot to think that move eax, 0 and xor eax, eax both use a single processor cycle and are exactly the same stress-wise? I can see code size being different, but I think I'm right about the first part.
Quote from: brew on April 25, 2007, 07:33 PM
that made me feel like a total idiot. this entire thing was useless.

iago

Quote from: Newby on April 22, 2007, 12:20 PM
Well if he knew bitwise operations well he would know xoring a number by itself results in 0. And it gets stuck on one of the two registers... both are eax... real hard choice to pick... :P
So why spend the extra human time figuring it out? One of the things you're taught if you ever want to be a real programmer is NOT to optimize your own code. Readability is far more important than optimization.

Quote from: Joex86] link=topic=16593.msg168252#msg168252 date=1177264561]
Now, am I an idiot to think that move eax, 0 and xor eax, eax both use a single processor cycle and are exactly the same stress-wise? I can see code size being different, but I think I'm right about the first part.
No Intel instruction uses one processor cycle. And xor uses less than mov, but not a significant amount.
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


MyndFyre

Quote from: Joex86] link=topic=16593.msg168252#msg168252 date=1177264561]
Now, am I an idiot to think that move eax, 0 and xor eax, eax both use a single processor cycle and are exactly the same stress-wise? I can see code size being different, but I think I'm right about the first part.

But they're not exactly the same stress-wise.  mov eax, 0 is 5 bytes because the 0 is stored four bytes wide, xor eax, eax is one.  Otherwise it wouldn't be much of an optimization.
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

brew

Wouldn't xor eax, eax be slower? the value of xor eax, eax needs to be calculated where mov eax, 0 moves a constant value into eax. Maybe not by very much (if anything at all) but yes, xor eax, eax is far more efficient anyways.
<3 Zorm
Quote[01:08:05 AM] <@Zorm> haha, me get pussy? don't kid yourself quik
Scio te esse, sed quid sumne? :P

Warrior

Quote from: effect on March 09, 2006, 11:52 PM
Islam is a steaming pile of fucking dog shit. Everything about it is flawed, anybody who believes in it is a terrorist, if you disagree with me, then im sorry your wrong.

Quote from: Rule on May 07, 2006, 01:30 PM
Why don't you stop being American and start acting like a decent human?

rabbit

Quote from: brew on April 22, 2007, 05:36 PM
Wouldn't xor eax, eax be slower? the value of xor eax, eax needs to be calculated where mov eax, 0 moves a constant value into eax. Maybe not by very much (if anything at all) but yes, xor eax, eax is far more efficient anyways.
Uhh...an operation can't be slower AND simultaneously more efficient than another operation...
Grif: Yeah, and the people in the red states are mad because the people in the blue states are mean to them and want them to pay money for roads and schools instead of cool things like NASCAR and shotguns.  Also, there's something about ketchup in there.

Skywing

Quote from: iago on April 22, 2007, 10:01 AM
Quote from: Dr. ♥ on April 22, 2007, 01:30 AM
i don't feel like xor eax, eax and mov eax, 0 are too different, as far as code recognition goes. it's not tough to see both, and recognize what both are doing.
That's true, because you're accustomed to it. But that's not necessarily true for everybody (like the guy in this thread), and I definitely wouldn't recosmmend that somebody does it.

xor reg, reg is pretty much the de-facto way to zero out a register as far as x86 goes, so I would tend to disagree in this case.

I wouldn't advise being overly "tricky" with assembler without good reason, but there are a couple of cases where some instructions have "well-understood" implied connotations beyond their "original intended" use.

To be realistic, the "xor reg, reg" construct is so widely used that all but the most inexperienced at x86 assembler will recognize what it means.

|