Sign in to follow this  
HaywireGuy

Unity PUSH ECX faster? Or MOV Count, ECX?

Recommended Posts

Extrarius    1412
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

Share this post


Link to post
Share on other sites
C-Junkie    1099
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.

Share this post


Link to post
Share on other sites
HaywireGuy    208
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 :)

Share this post


Link to post
Share on other sites
Zahlman    1682
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.

Share this post


Link to post
Share on other sites
fractoid    703
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
iMalc    2466
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.

Share this post


Link to post
Share on other sites
HaywireGuy    208
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!

Share this post


Link to post
Share on other sites
iMalc    2466
FYI: The point I think we were both making is that if it was in an innermost loop then timing it would easily tell you which is faster. If it isn't in an innermoost loop then it doesn't really matter as it isn't being executed very much and will barely make any difference. So there is no need to ask the question either way, at least not without explaining why you needed to ask the question, such as 'I can't get my profiling working'.
On the other hand if you were just too lazy to profile then...

Excuse my beverity btw.

Share this post


Link to post
Share on other sites
Extrarius    1412
Quote:
Original post by iMalc
FYI: The point I think we were both making is that if it was in an innermost loop then timing it would easily tell you which is faster. If it isn't in an innermoost loop then it doesn't really matter as it isn't being executed very much and will barely make any difference. So there is no need to ask the question either way, at least not without explaining why you needed to ask the question, such as 'I can't get my profiling working'.
On the other hand if you were just too lazy to profile then...

Excuse my beverity btw.
Even if it was in an inner loop, it'd have to be executing (MANY * MANY * MANY * MANY)999999 times to be noticable. If the times given by DukeAtreides076 are accurate, it might take ~3 cycles. On a 500MHZ machine, that means it would take 6*10-9 seconds, or 6 nanoseconds. On a modern machine (3.5GHz say) it would take a single nanosecond. You could do that operation a US Billion times per second. Unless you're writing for a REALLY slow machine, the difference is practically 0 and the time you wasted on the 'optimization' could be better spent optimizing the algorithms or implementations of something else..

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Partner Spotlight

  • Similar Content

    • By Levgre
      I have a design doc I can share, either contact me here, at levgree@yahoo.com, or on Discord (tag is levgre#1415). I am only going over some of mechanics in this post, with more focus on combat than campaign, as combat is the core of the game.  designers could possibly be welcome, at the least I don't ever mind getting additional ideas/feedback.
      Like said in the title, the game is inspired by Darkest Dungeon, but aspiring for deeper and more varied combat/campaign mechanics.
      Theme: the player controls a party of raiders that go on missions, getting loot, building up reputation and experience, etc.  These missions would often be populated areas like towns and forts, but also could be caves, forests, and other settings.  
      The player will control a party of 6 characters.  Changing group formation and individual character positions will be an essential part of strategy for all party compositions.   However, most characters will still be in frontline combat, as often they will be fighting off enemies from both sides (just less often from the rear).
      Characters, both friendly and enemy, will be able to die or be severely injured in one hit, and no magical healing available.  However they will be able to dodge or deflect most attacks until they run out of "stamina", at which point they become sluggish and easier to kill.  So gameplay wise, stamina behaves sort of like the regenerating shield in halo.  However if the player makes a tactical error or puts a character in a situation where they are outmatched, characters could still be wounded even at full stamina.  So individual battles are not the only threat, but also tiring  from many waves.  The players' group can rest when needed, but that will allow the enemies to ready their defenses or get reinforcements.  So speed and smart stamina management is encouraged.  Although, there will be some variety in approach, the player could have a more heavily armored team that slogs through tougher fights, or a lightly armored quick characters for a fast team that relies more on the element of surprise. 
      Weapon and armor choices for each character will be significant strategic decisions, based on battle formation and also the strengths and weaknesses of the party comp/individual characters.
      The exact setting is not yet decided, it could be realistic medieval, high fantasy medieval with demihumans and magical creatures and some level of magic, steampunk, etc..  The "raiders" could be seafaring viking types, fighting in a religious conflict like crusaders, or some of both.
      Thanks for reading, and lmk if you are interested or have any questions.
    • By Spronx
      Hi guys,
      I'm Andy from StriX Interactive and we are
      LOOKING FOR A LEVEL DESIGNER
      to join us on this incredible adventure of developing Blood Oath. Open world fantasy 3rd person RPG in the style of The Witcher.
      We plan to launch a Kickstarter campaign by the end of the year. So it's not a paid job yet.
      We need someone capable of making terrain according to the world map that we have and over all level design. We have a great team and want YOU to be a part of it.
      Contact us on our facebook page https://www.facebook.com/StriXInteractive/

    • By Java Nigga
      Hi there!
      We are JN Studios, we are looking for people to work with us in our project.
      About US:
      JN Studios is a 2 people amateur studio. we have like 1 year making games, but this is our first professional project to show it to the public. We are a programmer guy(Me) and a 3d modeller.
      About the game:
      Strategist Sniper is a RPG/FPS game, yes RPG and fps :v you awake in the middle of the unknown and a small voice tells you that you have to go through the world killing other snipers to get out of there. the mechanics of the game are based on the basic controls of games like League of Legends and in FPS games like Counter Strike.
      What we are looking for?
      actually we are looking for another c# programmer, a musician and an artist(for game illustrations for the marketing of the game).
      Profits Share:
      when the game is in a stable alpha phase we will create a campaign in Idiegogo to obtain money to finance the game. each of the project participants will receive a percentage depending on the work done.
      How to apply?
      just send us a email with a portfolio and in what you can help our team -       trabajojava1@gmail.com


      Devblog1.mp4
    • By cursetalegame
      Hello! I am building the main scene in Unity for a 3D cards game. My goal is creating "card slots" to place the different cards from a deck and use it as "buttons". The image below represents somehow what I want to develop. I have been reading and I think that I have to generate a canvas and place in my scene the slots where I want to place the cards, but I am not sure about it. Also, to use the cards, I don't know if setting buttons is the best option (maybe I should use images instead).
      All recommendations and tips are welcome

    • By cursetalegame
      Hi! We are looking for a unity 3D developer to join our small "beginners" team. We are 3 artists (illustration, concept and 3D modeling), 2 designers and 1 programmer (me). We are developing an online video game that we have already designed. Our goal is to create a small studio and build up this game to take it to video game events around Europe and try to find publishers. Also we want to learn step by step how to develop games, so, is better if you don't have a huge experience in developing
      For more information, or any question, you can send us an email to cursetalegame@gmail.com 
      Cheers
  • Popular Now