Others have covered the optimization side of things well so I won't repeat it, but there are tiny fragments of assembly all over the place -- they hold your system together.
Ask HN: What is hand-coded assembly language used for these days?
21–30 of 60 posts
Re: Ask HN: What is hand-coded assembly language used for these days?
#22When publishers/developers don't give a bleep, the fans take up the task of fixing the bugs themselves. I happen to run one such project in my spare time (for C&C: Red Alert 2), and it's amazing how much stuff is broken. It's not as "serious" as other projects mentioned here, but still a reason to know ASM. (And a good way to see bad programming practices in action :) )
Re: Ask HN: What is hand-coded assembly language used for these days?
#23IMVU hand-rolled its SSE skinning loops and parts of the software 3D lighting code, because only 2/3 of our customers have GPUs. We need to run well on five-year-old Dells with Intel graphics. (Direct3D on Intel isn't as good as a dedicated software renderer. We chose RAD's Pixomatic.) In addition, look at how popular netbooks are becoming. The Intel Atom is an in-order CPU. Imagine a hyperthreaded, 1.6 GHz 486... On…
Oh, I forgot about another huge case for writing assembly language... These days, we have tons of different languages talking to each other, all in the same program. In Mozilla, for example, JavaScript talks to C++ objects via XPCOM/XPIDL. Since the C++ objects expect data laid out on the C stack in a certain order and JavaScript has no notion of the C stack, there is a bit of platform-specific assembly code in the m…
Re: Ask HN: What is hand-coded assembly language used for these days?
#24Contrary to popular belief, assembly is not only used for performance. Ask the security industry for more info.
That has more to do with reading assembly than writing it by hand.
Re: Ask HN: What is hand-coded assembly language used for these days?
#25Anything that's worth spending time to do fast is worth spending time writing SIMD assembly for. You can get 5x, 10x, 20x, or more performance increases just by using the vector instructions given to you by the CPU. Until a magic compiler appears that can make proper use of them (read: never), hand-coded assembly will be critical for almost any application for which performance is critical, especially multimedia proc…
A compiler can't be made to make proper use of vector instructions? Why is that?
I am told that Fortran does better than C here; there is a reason it is still widely used in the scientific computing community, after all.
This is also part of the reasoning behind C99's new restrict keyword.
Re: Ask HN: What is hand-coded assembly language used for these days?
#26Anything that's worth spending time to do fast is worth spending time writing SIMD assembly for. You can get 5x, 10x, 20x, or more performance increases just by using the vector instructions given to you by the CPU. Until a magic compiler appears that can make proper use of them (read: never), hand-coded assembly will be critical for almost any application for which performance is critical, especially multimedia proc…
Re: Ask HN: What is hand-coded assembly language used for these days?
#27Earlier quoted context omitted.
I, for one, think that Assembly is just beautiful in its simplicity.
Having read and written assembly on a daily basis for years, I have to disagree entirely. The only simple thing about assembly is that it happens to map to machine code directly, but macros and quasi-instructions even make that iffy. There are so many idiosyncrasies in every ISA, so many ways in which the code you write has side effects. Assembly isn't just complex in practice, it's complex in concept. If you want si…
Re: Ask HN: What is hand-coded assembly language used for these days?
#28IMVU hand-rolled its SSE skinning loops and parts of the software 3D lighting code, because only 2/3 of our customers have GPUs. We need to run well on five-year-old Dells with Intel graphics. (Direct3D on Intel isn't as good as a dedicated software renderer. We chose RAD's Pixomatic.) In addition, look at how popular netbooks are becoming. The Intel Atom is an in-order CPU. Imagine a hyperthreaded, 1.6 GHz 486... On…
Oh, I forgot about another huge case for writing assembly language... These days, we have tons of different languages talking to each other, all in the same program. In Mozilla, for example, JavaScript talks to C++ objects via XPCOM/XPIDL. Since the C++ objects expect data laid out on the C stack in a certain order and JavaScript has no notion of the C stack, there is a bit of platform-specific assembly code in the m…
https://bugzilla.mozilla.org/buglist.cgi?query_format=advanc...
Re: Ask HN: What is hand-coded assembly language used for these days?
#29Contrary to popular belief, assembly is not only used for performance. Ask the security industry for more info.
That has more to do with reading assembly than writing it by hand.
Re: Ask HN: What is hand-coded assembly language used for these days?
#30Anything that's worth spending time to do fast is worth spending time writing SIMD assembly for. You can get 5x, 10x, 20x, or more performance increases just by using the vector instructions given to you by the CPU. Until a magic compiler appears that can make proper use of them (read: never), hand-coded assembly will be critical for almost any application for which performance is critical, especially multimedia proc…
Well, you can still use C with GCC and Intel intrinsics I guess.
The first reason is the whole category of optimizations that the compiler is worse than a human at (like register allocation) or cannot do effectively at all (messing with calling conventions, computed jumps).
The second reason is more subtle: in any case that you abstract yourself from some part of a problem, you inherently create a less efficient solution.
For example, intrinsics mean that you don't have to manually allocate registers. But this also means that if your algorithm uses too many registers and it would be more efficient to modify it to require fewer (and thus not need spills), you will have no way of knowing such a thing. By insulating yourself from that layer of complexity, you've also limited your ability to make higher-level optimizations that improve lower-level performance.
This applies on practically every level possible: any method of abstraction, no matter how well designed, will always in some fashion reduce the maximum performance you can achieve. Of course, this doesn't mean abstraction is bad--it provides an often-useful tradeoff between developer time and performance.