Home | Community | Message Board


Kratom Eye
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: 1,051
Last seen: 8 days, 6 hours
Pentium Microprocessors
    #4611555 - 09/02/05 05:27 AM (12 years, 9 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: 29 days, 14 hours
Re: Pentium Microprocessors [Re: encryptor]
    #4611602 - 09/02/05 06:45 AM (12 years, 9 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 649 6 05/09/09 08:01 PM
by deCypher
* gcc inline assembly on ia32 SeussA 820 6 06/10/04 03:10 PM
by Seuss
* The FBI’s Next Generation Identification System is the largest biometric database ever assembled. tdubz 212 3 06/01/16 07:21 PM
by Algo
* Pentium 4 with 1066 FSB daba 841 10 05/22/04 02:06 AM
by daba
* Linux filter Wireless card PCI for Pentium 2 OrganizedChaos 389 5 05/26/09 11:31 PM
by Tripp420
* how much has changed since the intel pentium 4 processor was designed for the 448 socket imachavel 567 5 01/13/12 10:08 PM
by johnm214
* good XP torrent/instructions? t00th 502 7 10/29/09 09:22 PM
by iateshaggy
* How to read arabic instructions Da2ra 260 3 06/13/13 05:11 PM
by Da2ra

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

Copyright 1997-2018 Mind Media. Some rights reserved.

Generated in 0.023 seconds spending 0.003 seconds on 19 queries.