Home | Community | Message Board


High Mountain Compost
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
Offlineencryptor
 User Gallery

Registered: 05/16/03
Posts: 973
Last seen: 2 days, 11 hours
Pentium Microprocessors
    #4611555 - 09/02/05 05:27 AM (11 years, 7 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
OfflineSeussA
Error: divide byzero

Folding@home Statistics
Registered: 04/27/01
Posts: 23,480
Loc: Caribbean
Last seen: 3 months, 18 days
Re: Pentium Microprocessors [Re: encryptor]
    #4611602 - 09/02/05 06:45 AM (11 years, 7 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 633 6 05/09/09 08:01 PM
by deCypher
* Statistics time: Programming Languages and Programmers
( 1 2 all )
delta9 3,253 26 05/16/07 02:17 PM
by SymmetryGroup8
* Pentium 4 with 1066 FSB daba 822 10 05/22/04 02:06 AM
by daba
* Chimp Who Learned American Sign Language: Dies DiploidM 985 10 11/08/07 01:20 AM
by johnm214
* Favorite Programming Language
( 1 2 all )
D4NK 1,916 35 03/16/09 03:12 AM
by zouden
* gcc inline assembly on ia32 SeussA 795 6 06/10/04 03:10 PM
by Seuss
* Spanish language lesson torrents...advice/suggestions? ToTheSummit 6,189 9 08/28/08 05:32 PM
by ToTheSummit
* Programing languages help Baeosistine 661 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, Diploid, automan
454 topic views. 0 members, 3 guests and 3 web crawlers are browsing this forum.
[ Toggle Favorite | Print Topic | Stats ]
Search this thread:
Gaiana.nl
Please support our sponsors.

Copyright 1997-2017 Mind Media. Some rights reserved.

Generated in 0.04 seconds spending 0.006 seconds on 14 queries.