-
Assembly for graphics
Hi,
I am looking to learn assembly language, so that I can write faster graphics routines. I know some fairly basic stuff about architecture (for example, I know what a register is, what an ALU is, what the program counter and accumulator are) and I know C/C++ to an intermediate level.
I want to be able to learn an assembly syntax which can be used on Windows and Linux. As far as I have seen, the best ones to learn are FASM or NASM. However I cannot find any good books which focus on those. A lot of places recommend on "Art of Assembly" which seems to use MASM. However, it is said that trying to learn another assembly syntax after learning MASM is hard because MASM uses something called HLA which the others do not.
I am a bit lost and I could do with some guidance as to a good book/books to start off with!
-
Don't use MASM's HLA (high-level assembly) features and you'll be pretty much set for NASM. Besides, NASM has its own macro engine, too.
-
Well, depending on what you are doing it will be hard for you to optimize more than the library/compiler in question. Are you having FPS problems? Maybe just some profiling and optimizing of parts of your code will do you better.
I know ASM is good sometimes, but most times it is hard to make a difference using it compared to what the graphics API/compiler already has/does.
Just my $0.02
-
If you google for NASM tutorials you can find several resources. I didn't go through each of them to check the quality but this one seems to have what you are looking for. http://webster.cs.ucr.edu/AsmTools/NASM/index.html
-
> I am looking to learn assembly language, so that I can write faster graphics routines
I thought most high performance graphics basically use a driver to send commands to a graphics processor to do all the hard work of bit-bashing in the pixel buffer.
If you're thinking of using ASM to do your own bit-bashing in pixel memory, then I'd say you're probably onto a losing battle, no matter how good a programmer you are.
-
Assembly for graphics is a lost cause. You will never be faster than the hardware and with the advent of pixel shaders you don't need assembly anyways.
The video GPU can blit more pixels to the screen in 1 milli-second than there are pixels in the highest resolution possible on the card.
I doubt a rep stosd is going to be faster than that. rep stosd will use the bus to pull data from the memory while the video card will pull it from it's onboard RAM and leave your code in the dust. Get with the times and get with the hardware. If you want extremely blazing fast graphics with excellent quality then put away the club and come out of the cave into the wonderful new world of shader programming. Or you can insist on being a caveman and using ancient tools.
Assembly has it's place in game programming, but this is not one of those places and with more and more functions becoming available via the driver model, assembly is not going to help anything.