Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Crosseyed

Eww assembly is ugly...

This topic is 5720 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Yes, it is very ugly indeed, but i am being forced to learn it. Though now i am begining to enjoy it(just a little). Its kinda like turning a game''s difficulty up to hard after you beat it already on medium(c++). Anyways, now that i know assembly and its supposed to good for optimisation I want to know what everybody else uses it for?? What should i be replacing in my c++ projects with inline assembly, any suggestions.

Share this post


Link to post
Share on other sites
Advertisement
quote:
Original post by Crosseyed
its supposed to good for optimisation

Well, yes and no. Knowing assembly is not the same as knowing how to optimize assembly. And most compilers are smart enough to do as good a job as or better than you could.

quote:
What should i be replacing in my c++ projects with inline assembly, any suggestions.

Nothing, until you profile your code. Then you can identify which functions are taking up all your time, and do stuff with those. But you will realize much more benefit from logical optimization than from code optimization.


Don''t listen to me. I''ve had too much coffee.

Share this post


Link to post
Share on other sites
Don''t optimise early.

90% of your program''s execution time is spent in 10% of the code. When you''ve finished writing pretty much everything, you should profile your stuff, think how to optimise the slow code at an algorithm level first, and only as a last resort rewrite it in assembly.


Helpful links:
How To Ask Questions The Smart Way | Google can help with your question | Search MSDN for help with standard C or Windows functions

Share this post


Link to post
Share on other sites
i find profiling fascinating.

all these functions rise to the top as i manipulate the data to exclude stuff i''m not interested in optimising at the moment. i get a feel for where the program is spending most of it''s time or how long it''s spending in specific places or how long it takes to get from a to b or how many times it calls structors (making sure they match). then i try out using a different algorithm or a standard list rather than a hand rolled one (this is legacy code i''m working on).

you can still optimise a lot in c++ before having to eventually pull out the asm. only then take a look at the code generated in areas you have evidence there is a problem. there''s a good chance you can get adequate improvements by reorganising your c++ first and then you can tweak the assembly.

Share this post


Link to post
Share on other sites
Assembly language is cleaner and simpler than C++; by nature, asm has to be very simple. C++''s power lies not in simplicity, but in organization.


Don''t listen to me. I''ve had too much coffee.

Share this post


Link to post
Share on other sites
I find x86 assembly to be incredibly ugly when compared to the lovely consistency and flexibility of MIPS/SPARC assembly, particularly when you have access to (and who doesn''t) a macro processor.

There''s very rarely a need to write assembly anymore. Programmer comprehensibility is far more valuable than compiler specificity. In fact, I would only write assembly on a platform that lacks a decent C or C++ compiler, or when implementing a compiler myself.

Share this post


Link to post
Share on other sites
typically nowadays, the best use for assembly in serious programming is when you need to use processor extensions such as mmx, 3dnow and sse

Share this post


Link to post
Share on other sites
quote:
Original post by Useless Hacker
Personally, I find C++ to be more ugly than assembler.

[edited by - Useless Hacker on October 1, 2002 6:30:26 AM]


damn right. asm has only 3 types of instruction: math, data movement and logical jumps. it that''s too DIFFICULT for some people, i think we have a case of habit more than that either language is easier.

one thing to bear in mind: compilers push and pop all registers you use in inline code so it only makes sense to write a significant portion of a function in pure assembly. i heard microsoft deliberately sabotages inline assembly to make its own compiler look good .

to tell the truth, assembly is vastly superior to most langiages for one reason: it is EXPLICIT and UNAMBIGUOUS. people argue its dangerous becuase theres no way to tell if a number is a fraction or pointer so its easy to get confused with no typing. that isn''t being ambiguous, that''s being literal.

bad assembly is ugly. amuter optimisation is ugly. simplicity is beautiful.

********


A Problem Worthy of Attack
Proves It''s Worth by Fighting Back

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!