Skip to main content
gamedev.net
🔒 Locked

Assembler

Started by ArnoAtWork May 25, 2002 at 8:37 AM 3 replies 700+ views
Original Post
ArnoAtWork
ArnoAtWork
Currently developping a mathematics library, I try to use a bit of assembler to optimise my code using inline assembler. But looking for help, I don''t find anything(what register to use). Also I don''t want to use a Pentium assembler, I would like a common assembler to be used by any machines. So, where to find any help? Thanks.
Michalson
Michalson
Given the knowledge of assembler you demonstate, I would suggest that you not try using it to optimize. Assembly programming is not magic, it will not make your program run any faster just by writing the code in it (in fact, compared to pro [optimizing] versions of todays compilers your code will run slower). To make assembly code that is faster than what is produced by todays compilers you need to be fairly experienced in the tricks and tweaks that can be done (and pentium optimizations are definitely one of the things you need to know).

For now just write your code in C/C++ (or whatever you''re using). The best optimizations (read: the ones that give the biggest speed increase) can be written in high level languages.
ArnoAtWork
ArnoAtWork
So, in this case, I stop loosing my time on internet looking for help.

Thanks.
Askadar
Askadar
Assembler is always machine dependent. Hight Level Languages were created to overcome this.

You might want to read something about the history of C, and why it became so succesful.

Kill mages first!
Michalson
Michalson
I don't mean that as a put off to learning assembler, only that assembly doesn't become useful for optimizing until you've mastered it. Since I assume you don't want to wait a year or more to write your library I suggested not using assembler for it.

If you want to learn you can start with the basics by reading
The Art Of Assembler

Then move on to advanced techniques:
Optimization
Optimization Strategies For The Pentium® Processor
Intel Architecture Optimizations Manual
Pentium Optimizations
Pentium loop optimizations

as well as some of the manuals here, and the websites sandpile.org and x86.org


The fact is that writing in assembler is the last step you want to take when optimizing code (when all other steps have been exhausted).

Step 1. Better algorithms: No matter how much you hand optimize a bubblesort, it will still be slower on large data sets than a quicksort written in Visual Basic.

Step 2. Implementation: This is probably the best area for 'optimization'. There are countless techniques for improving your implementation of an algorithm. Using more effiecient data types, using lookup tables, aligning data, minimizing cpu intensive instructions (using things like shifts in place of divides and multiplies) and unrolling loops are just the beginning.

Step 3. Assembler: Given the maintence nightmare that is assembler you should avoid it until you have exhausted 1 and 2 to the best of your abilities. If you are rewriting code in assembler it should not be to simply translate what you are doing in a high level language (your compiler does a better job of that). You need to be taking advantage of your knowledge of pipelines to origanize instructions, using flag shortcuts to do several things with one instruction and creating self modifying code where needed.

[edited by - Michalson on May 25, 2002 10:52:32 AM]

[edited by - Michalson on May 25, 2002 10:53:10 AM]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.