Home | Community | Message Board

Everything Mushrooms
Please support our sponsors.

General Interest >> Science and Technology

Welcome to the Shroomery Message Board! You are experiencing a small sample of what the site has to offer. Please login or register to post messages and view our exclusive members-only content. You'll gain access to additional forums, file attachments, board customizations, encrypted private messages, and much more!

Jump to first unread post. Pages: 1
 User Gallery

Registered: 05/16/03
Posts: 1,029
Last seen: 1 day, 12 hours
Pentium Microprocessors
    #4611555 - 09/02/05 05:27 AM (12 years, 3 months ago)

Why is optimized assembly language code the fastest programming language?  Anyone know?  I'm thinking it's because the code is simple and directly related to how the computer functions.  Furthermore, the language doesn't hog memory and executed quickly and efficiently.  Anymore guesses? :syringe: :mushroom2:

Post Extras: Print Post  Remind Me! Notify Moderator
Error: divide byzero

Folding@home Statistics
Registered: 04/27/01
Posts: 23,480
Loc: Caribbean
Last seen: 11 months, 3 days
Re: Pentium Microprocessors [Re: encryptor]
    #4611602 - 09/02/05 06:45 AM (12 years, 3 months ago)

> Anymore guesses?

Do you want a guess, or do you want to know the real reason? I will assume the later.

A computer executes machine code. Machine code is simply a sequence of numbers. These numbers mean something to the machine (hence the name). They tell the machine to load values into memory, or to move stuff around, or to add things, etc. Regardless of what language is used to write a program, in order for the computer to execute the program, the program must be translated into machine code.

Assembly language is a human readable form of machine code. On the x86, the machine code instructions "0xCD 0x20" are the exact same as the assembly instructions "int 20h" (call interrupt 20 hex). An assembler is used to translate assembly into machine code.

Higher level languages, such as C++, use a compiler to translate the C++ code into assembly, then use the assembly to translate the assembly into machine code. A handful of lines of C++ can result in hundreds of lines of assembly.

The compiler does the best job it can to optimize the assembly it generates. This is a very complex procedure. The compiler has to map the needs of the program into the limited resources of the computer.

The reason hand written assembly is often faster than compiler generated assembly is because humans are better at mapping the needs of the program into the limited resources of the computer than a compiler is. We have a better picture of what the program is doing, how it will behave, etc.

Modern compilers have gotten very good at optimizing and CPU designs have gotten much better as well. It is very difficult to write assembly code that out performs a compiler on most modern systems. In the old days, the benefit of hand coded assembly could be massive, but today it is mostly a waste of time.

One particular place where hand coded assembly still pays off is when working with specialized instruction sets, such as SSE on the x86. The SSE instructions are used to do common mathmatical operations seen in video (and audio) compression. If you write a program to decode mpeg, the compiler is going to use regular ALU instructions rather than the special SSE instructions. If you want to use the SSE instructions, you will have to write the assembly by hand.

Just another spore in the wind.

Post Extras: Print Post  Remind Me! Notify Moderator
Jump to top. Pages: 1

General Interest >> Science and Technology

Similar ThreadsPosterViewsRepliesLast post
* What books/tutorials/compilers for Assembly Language do you recommend? deCypher 641 6 05/09/09 08:01 PM
by deCypher
* Statistics time: Programming Languages and Programmers
( 1 2 all )
delta9 3,394 26 05/16/07 02:17 PM
by SymmetryGroup8
* Pentium 4 with 1066 FSB daba 837 10 05/22/04 02:06 AM
by daba
* Chimp Who Learned American Sign Language: Dies DiploidM 1,002 10 11/08/07 01:20 AM
by johnm214
* Favorite Programming Language
( 1 2 all )
D4NK 2,016 35 03/16/09 03:12 AM
by zouden
* gcc inline assembly on ia32 SeussA 804 6 06/10/04 03:10 PM
by Seuss
* Spanish language lesson torrents...advice/suggestions? ToTheSummit 6,512 9 08/28/08 05:32 PM
by ToTheSummit
* Programing languages help Baeosistine 675 6 10/04/08 08:49 PM
by zouden

Extra information
You cannot start new topics / You cannot reply to topics
HTML is disabled / BBCode is enabled
Moderator: Lana, trendal, automan
460 topic views. 0 members, 2 guests and 0 web crawlers are browsing this forum.
[ Toggle Favorite | Print Topic | Stats ]
Search this thread:
Crestline Sales - MycoPath
Please support our sponsors.

Copyright 1997-2017 Mind Media. Some rights reserved.

Generated in 0.024 seconds spending 0.005 seconds on 19 queries.