PUSH ECX faster? Or MOV Count, ECX?

Started by
10 comments, last by Extrarius 19 years, 5 months ago
Hi guys I'm back, back with a stipid question. So which one is faster? Considerin' that both can be used and I have to choose one. Thanks!
Advertisement
Unless you're programming a 486 or earlier, it won't make a difference.
I'd probably use the stack directly with push since its more 'assembly-like' imo. Using variables is for sissies =-P
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk
Given that (non-register passing) function calls have their parameters passed with PUSHes for every compiler that I've ever seen, rather than a SUB and a bunch of MOVs, I'd say jsut go with PUSH.
Thanks guys, that's helpful. I'm goin' with BUSH, I mean, PUSH.

Anyway my friend told me that PUSH is built in, so it only
occupies a single code byte (0x51), whereas "MOV Count, ECX"
occupies three code bytes and it's slower. Yeah and I saw that
in my dissasembly too :)
If you have to ask (i.e. can't figure out how to test it for yourself), then you are pretty much automatically not qualified to make use of the answer.
Not necessarily. It may be that he could go forth and do a bunch of benchmarks, and infer, from the data gained, which approach is faster. But instead of doing all that stuffing around, he pops the question on GameDev.Net, on the assumption that with so many asm programmers around, someone's probably already done the groundwork and he'd be wasting his time to repeat it.

Linkay. Which may or may not be useful.
Quote:Original post by HaywireGuy
Thanks guys, that's helpful. I'm goin' with BUSH, I mean, PUSH.

Anyway my friend told me that PUSH is built in, so it only
occupies a single code byte (0x51), whereas "MOV Count, ECX"
occupies three code bytes and it's slower. Yeah and I saw that
in my dissasembly too :)


These days pretty much all of the ALU operations (including MOV and PUSH/POP) are hardwired into the chip already. Yes the alternate encoding for PUSH register operand onto the stack is only one byte, and I think a MOV mem/reg operation is two bytes followed by up to a four byte memory value.

The Intel Optimization manual gives PUSH with latency of 1.5 and throughput of 1, while MOV has a latency of 0.5 and throughput of 0.5. Remember that these are just estimates, and what usually matters more on modern processors is memory and cache performance. Either way I doubt you'll get much speed difference between the two.
Quote:Original post by Zahlman
If you have to ask (i.e. can't figure out how to test it for yourself), then you are pretty much automatically not qualified to make use of the answer.
Ain't that the absolute truth!

I was going to somehow say the same thing, but you couldn't have said it better.
"In order to understand recursion, you must first understand recursion."
My website dedicated to sorting algorithms
Zahlman, I was waitin' for a reply like that given by
DukeAtreides076 and the rest, which my test application won't
tell me. So, yah, I'm here.

Cheers fractoid, I'm sure that's gonna be useful :)

Duke, I'm sure that's true, maybe I'm just being a lit'
paranoid when I have these MOVs in a very tight loop that
executes millions of times. But anyway, thanks!
Thanks iMalc, that's the ultimate truth, that's why I
was "asking a stupid question". See?

This topic is closed to new replies.

Advertisement