Are there any significant advantages in using Assembler any more?
My intuitive take so far seems to be that the performance speed that can be gained is simply not worth the down-chunking in logical organization (though MASM looks very similar to c syntax nowadays).
It used to be that assembler would still beat the best c compilers by a good 20-30%. Compilers have gotten a lot smarter, though. Does anyone have any good solid data on these issues?
Was it worthwhile? Did the act of creation free your soul?
Edited by - ShepherdOfChaos on 5/26/00 12:18:30 AM
Was it worthwhile? Did the act of creation free your soul?
One advantage is that sometimes an optimizing compiler will introduce bugs. Usually not the case, but sometimes it makes too many assumptions about mathematical laws that aren''t true on computer arithmetic (communtivity, associativity, etc.). Once we were working with a legacy FORTRAN library that had a known bug in it regarding floating point input. The solution was that on one of the input variables you did something screwy like add .5 then subtract .5. Well, the compiler would constant fold that right out, so we had to inline some assembly in order to force it to occur. (I suppose there were a couple of options available without using assembly, but it seemed the most elegant at the time.)
Also a standard optimising compiler won''t use MMX, SIMD or 3DNow. These things are the main reason that I am learning assembler.
Yesterday I downloaded the AMD 3DNow SDK, this has a quaternion demo and by just using about 50 lines of assembler using the 3DNow instructions the framerate jumps from 23fps to 39fps! I don''t expect you would get this type of increase in a game, but still if you can SIMD optimise the most frequently called and slowest parts of your code I don''t see why 10-15% increases in overall speed aren''t possible. I''m not sure whether using MASM and linking object files is faster than the MSVC inline compiler, but with inline assembler you can implement it so that you can still keep the overall structure of your code the way you like it.
-- Kazan - Fire Mountain Games --
Yesterday I downloaded the AMD 3DNow SDK, this has a quaternion demo and by just using about 50 lines of assembler using the 3DNow instructions the framerate jumps from 23fps to 39fps! I don''t expect you would get this type of increase in a game, but still if you can SIMD optimise the most frequently called and slowest parts of your code I don''t see why 10-15% increases in overall speed aren''t possible. I''m not sure whether using MASM and linking object files is faster than the MSVC inline compiler, but with inline assembler you can implement it so that you can still keep the overall structure of your code the way you like it.
-- Kazan - Fire Mountain Games --
I've just wrote a simple program to show just how much faster using 3DNow is. It isn't really going to give you that much of an idea of the speed increase you'll get from a game but it's interesting anyway.
The C part of the program looks like this (num and num2 are both 32bit floats):
Now the same thing in inline assembler:
The results on my machine for the C code was 5487ms, for the 3DNow code it was 2629ms.
-- Kazan - Fire Mountain Games --
Edited by - Kazan on May 26, 2000 9:48:19 AM
Edited by - Kazan on May 26, 2000 10:25:09 AM
The C part of the program looks like this (num and num2 are both 32bit floats):
time = timeGetTime();
for(i = 0; i < 100000000; i++)
{
num += num2;
}
cout << (timeGetTime() - time) << endl;
Now the same thing in inline assembler:
time = timeGetTime();
__asm femms
for(i = 0; i < 100000000; i++)
{
__asm {
movd mm0,[num]
movd mm1,[num2]
pfadd (mm0,mm1)
movd [num],mm0
}
}
__asm femms
cout << (timeGetTime() - time) << endl;
The results on my machine for the C code was 5487ms, for the 3DNow code it was 2629ms.
-- Kazan - Fire Mountain Games --
Edited by - Kazan on May 26, 2000 9:48:19 AM
Edited by - Kazan on May 26, 2000 10:25:09 AM
If anyone is interested I just changed the test to take the reciprocal (1/x) of 100.0f and place it into a different variable. The test was the same as the last with 100,000,000 repetitions. 3DNow! ASM using pfrcp got 2421 ms (2.4 seconds), whilst poor old MSVC 6.0 code only managed 15320 ms!!! (15.3 seconds).
-- Kazan - Fire Mountain Games --
-- Kazan - Fire Mountain Games --
> Are there any significant advantages in using Assembler any more?
YES
The motto today seems to be: "Not fast enough - but a faster computer yourself!"
Assembly will free your soul, but test your braincells! It''s very hard, and getting even more difficult. It''s only for the hardcore programmers. But don''t expect too much result, unless speed is your game!
YES
The motto today seems to be: "Not fast enough - but a faster computer yourself!"
Assembly will free your soul, but test your braincells! It''s very hard, and getting even more difficult. It''s only for the hardcore programmers. But don''t expect too much result, unless speed is your game!

This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement