Is Assembly still programmed in for todays games?

Started by
9 comments, last by wyrd 20 years, 3 months ago
I remember ways back, that Assembly was used for critical math calculations and game loops. I was wondering, is this still practiced? Or are compilers advanced enough now to optimize for acceptable performance?
Advertisement
The compilers have come a long way in optimizing for simple things that in the past, assembly would have been used for. Even then though, it would still be good to learn assembly. On consoles, especially the GBA, assembly is very important.
---------------------Ryan Bujnowicz[ vangelis ]
Yes it''s used. Compilers might be advance, but common compilers have lots of quirks that make your programming worse than MASM.
Assembly is also making a comeback in low level pixel shaders like OpenGL fragment and vertex programs.

I think the general theory behind assembly would be good to know for things like that.

~Graham

----
while (your_engine >= my_engine)
my_engine++;
general its used for stuff like MMX etc were the compiler doesnt do the work for you, but ONLY when really needed (profiled)

Assembler is used for pixel shaders atm, however as both DX and OGL have a high lvl language now i dont see that lasting for long
quote:Original post by wyrd
I remember ways back, that Assembly was used for critical math calculations and game loops. I was wondering, is this still practiced? Or are compilers advanced enough now to optimize for acceptable performance?


While compilers have advanced a bit, processors have gotten much faster. Something that would have been incredibly slow without hand optimized asm back in the day, will run just fine with plain C code today. Not because the compiler is doing anything special, just because your CPU is now MUCH faster. In 98 I got a P2-300Mhz, w/ 33 MHz bus. Now I''ve got a P4-2.8GHz, w/ dual 800 MHz bus. That''s a 9.3 times increase in CPU speed, and a 48.5 times increase in data transport speed... add in extra speed for hyper threading (lets say Hyper threading only helps by 1/3, that brings up the processor increase from 9.3 times to almost 13 times), SIMD instructions like SSE and MMX, branch prediction, lower clock counts per instruction... it all adds up to a huge amount of processing power.

So, something that would have taken 1/2 an hour, now takes something like 2 minutes... without changing the code, just the processor... there''s simply much less reason to optimize most code anymore. You''d be amazed what your machine could do, if it was coded tightly. It''s a few thousand times faster than the original PC XT. Hundreds of times faster than a 386 when we had things like the future crew demos.
on consoles, it''s still very much on the agenda, especially on the PS2. it''s hard for the compiler to do a perfect job on that, because the PS2 is designed like a insane powerplant. And pixel?vertex shaders, as said above.

As said above, On the PC, you can still optimise stuff, like make use of MMX libraries and others on things like vector libraries, matrices, ect... But you can also improve performance with a good old hand written assembly block on stuff like tree trasversals and other very costly parts of the code. Usually, you start of by writting tighter C code, then to get the extra juice, you can spend 1 hour analysing the machine output, see if it is sensible, else, decide to write your own version, or tighten up the compiler binary output. But do the assembler at the very very end, or it''s painful.

The usual Profile/optimise/profile/optimise/...

Everything is better with Metal.

Hmm, interesting. Thanks for the responses.
It is less that compilers have gotten better than that processors have gotten much faster. I used to write code for the sub 5MHz Super Nintendo--a 16-bit processor. And now you can assume a bare minimum of 500-800MHz. And it''s becoming realistic to assume 2GHz. That''s 400x faster in raw clockspeed than the SNES processor, even ignoring that it was (a) 16-bit, and (b) only executed one instruction every 3-7 cycles, as opposed to the 2-3 per cycle that''s common today.
Compilers tend to do a better job of loop unrolling, and memory managment, but ASM is still the fasting language. Learning ASM will help you understand what is going on "under the hood" of your C++ apps. It will also help you understand byte-code. About the only time you''d need to use ASM in your code is for ultra-fast memory transfers. Using ASM, you can transfer memory 4 bytes at a time!

This topic is closed to new replies.

Advertisement