Eww assembly is ugly...
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.
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.
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
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
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.
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.
Personally, I find C++ to be more ugly than assembler.
[edited by - Useless Hacker on October 1, 2002 6:30:26 AM]
[edited by - Useless Hacker on October 1, 2002 6:30:26 AM]
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.
Don''t listen to me. I''ve had too much coffee.
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.
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.
typically nowadays, the best use for assembly in serious programming is when you need to use processor extensions such as mmx, 3dnow and sse
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement