Archived

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

wyrd

Is Assembly still programmed in for todays games?

Recommended Posts

wyrd    112
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?

Share this post


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

Share this post


Link to post
Share on other sites
Raghar    96
Yes it''s used. Compilers might be advance, but common compilers have lots of quirks that make your programming worse than MASM.

Share this post


Link to post
Share on other sites
gwihlidal    1004
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++;

Share this post


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

Share this post


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

Share this post


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

Share this post


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

Share this post


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

Share this post


Link to post
Share on other sites
digitec devil    206
quote:
Original post by gwihlidal
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++;


Any comeback that assembly made because of shaders will soon be over. DirectX has the HLSL and OpenGL also has a high level language for it''s shaders(in 2.0 anyway). But assembly doesn''t take long to learn, and is of course an asset to any programmer who would be interested in the efficiency of his code.

Share this post


Link to post
Share on other sites