Click here to Skip to main content
Click here to Skip to main content

Why Learn Assembly Language?

By , 28 Jun 2010
 

Introduction

REVISION 2

"Assembly language? Isn't that the hard to read instructions on how to assemble your brand new computer desk?"...

No..

What is Assembly Language?

x86 Assembly is a programming language for the x86 class of processors (specifically the 32bit x86 processors IA-32 - http://en.wikipedia.org/wiki/IA-32). The instruction set defined by the IA-32 architecture is targeted towards the family of microprocessors installed in the vast majority of personal computers on the planet. Assembly language is machine specific and considered a "low level" language. This means that the code and syntax is much closer to the computer's processor, memory, and I/O system. A high level language is designed with keywords, libraries, and a syntax that introduces a high level of abstraction between the language and the hardware.

Background

I thought assembly was a dead language, why waste the time?

Though it's true, you probably won't find yourself writing your next customer's app in assembly, there is still much to gain from learning assembly. Today, assembly language is used primarily for direct hardware manipulation, access to specialized processor instructions, or to address critical performance issues. Typical uses are device drivers, low-level embedded systems, and real-time systems (EDIT:Thanks Trollslayer). The fact of the matter is, the more complex high level languages become, and the more ADT (abstract data types) that are written, the more overhead is incurred to support these options. In the instances of .NET, perhaps bloated MSIL. Imagine if you knew MSIL. This is where assembly language shines. (EDIT)Assembly language is as close to the processor as you can get as a programmer so a well designed algorithm is blazing -- assembly is great for speed optimization. It's all about performance and efficiency. Assembly language gives you complete control over the system's resources. Much like an assembly line, you write code to push single values into registers, deal with memory addresses directly to retrieve values or pointers. To write in assembly is to understand exactly how the processor and memory work together to "make things happen". Be warned, assembly language is cryptic, and the applications source code size is much much larger than that of a high-level language. But make no mistake about it, if you are willing to put in the time and the effort to master assembly, you will get better, and you will become a stand out in the field.

So why should you care?

Points of Interest

Wirth's Law

I remember dialling into a BBS on my 486 with my brand new 2400bps modem. Fast-forward 14 years and now we are only limited by our imagination. With all of these amazing technological breakthroughs, there is a glaring anomaly; a paradox. This is referred to as Wirth's law. Wirth's law states that software is getting slower more rapidly than hardware becomes faster. There's no one reason why this is the case, but I'd like to think that the further we as developers drift away from the lower level details of software development, we write less than stellar (inefficient code). Hold the phone! I'm not calling anyone stupid. It's just that these new languages and supercharged processors have abstracted us so far from the machine, that we no longer have to be concerned with things like garbage collection, variable initialization, memory address pointers, etc. All of these features and more are now standard in today's languages/runtimes/IDEs. The result is a new breed of developers that rely on superior hardware power for performance rather than striving to write concise, cohesive, efficient code.

My Eyes are Open!

I realize now that learning assembly language will teach me about the inner workings of the computer. I'll learn how the CPU/CPU registers work with memory addresses to achieve the end result one instruction at a time. This doesn't mean that I'm going to begin coding everything in assembly, however, I will learn which data types to use and when. I'll learn how to write smaller, faster, more efficient routines. I will understand software development at a level that most of my peers don't. I'm even opening up to the possibility of looking into writing my own compiler.

So if you are serious about getting a leg up on the competition in your field, I'd recommend trying to learn assembly language.

Resources on Learning Assembly

Introduction to x86 Assembly Language

History

I plan to update this blog with links to tutorials/articles/books/sample source code.

Well, as always,
Thanks for reading.
Buddy B.

http://www.twitter.com/budbjames
http://www.bytepushers.com

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

bjames02
Software Developer bytepushers.com
United States United States
Member
I'm a 28 year old software engineer from Tennessee. I've been programming since I was 13 years old. I'm fortunate enough to be able to do what I love for a living.
 
VB.NET, ASP.NET, C#, assembly, HTML, JavaScript, AJAX
 
I'm MCP, MCAD, MCSD.NET certified.
 
follow me on twitter
 
http://www.twitter.com/budbjames

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionMy vote of 5memberJosef Manurung30 Dec '11 - 6:00 
The is the only language that gives you the most knowledge you will ever need to know about programming.
QuestionAssembly language.membernigel wright3 Oct '11 - 11:10 
In the 1980's assembly language was the way I went.
I designed a cad program that was 330,000 lines.
Assembler taught me to be tidy with my code and make it readable as trying to go back over something uncommented is a nightmare. Assembler also taught me about programming detail like writing directly to the video card hardware. These days you cant do that in assembler as Win7 will kick up a fuss and not allow it.
GeneralFew Queriesmemberpopchecker13 Sep '10 - 15:48 
I think I found this article on a right time. I know a few high level languages which I learned myself. But in case of assembly language, I think I am going to fail. Right now I am struggling with FASM on a windows machine for two weeks. I couldn't gain more than writing few lines to print something on a DOS console.
 
Can you please suggest me a good assembler, book, operating environment and debug tool for a beginner?
GeneralRe: Few Queriesmemberbuddy.james23 Sep '10 - 21:20 
Thanks for reading and leaving feedback. Just hang in there, if you practice, you will learn. You do have to write a lot of code to do very little, however, this is because you are spoon feeding the processor it's instructions. You gain an understanding of how your machine works.
 
As far as books go I'd recommend Assembly Language Step by Step http://www.amazon.com/Assembly-Language-Step-step-Programming/dp/0471375233
 
An assembler try NASM or MASM
 
And for a debugger, try DEBUG.
 
I hope this helps.
 
Thanks again.
GeneralFor a different take on the pros & cons of asm over other languages.memberDigital Thunder7 Jul '10 - 9:24 
This link http://www.roesler-ac.de/wolfram/hello.htm[^] lists 428 different programming language examples that all produce the same result: to print 'Hello World' This is a real eye opener into how convoluted even the simplest task can be in some languages! It would have been even more interesting if the author of the article could have stated the size of the executable for programs that produced an executable.
I think computer viruses should count as life. I think it says something about human nature that the only form of life we have created so far is purely destructive. We've created life in our own image.
Stephen Hawking

GeneralRe: For a different take on the pros & cons of asm over other languages.memberbjames027 Jul '10 - 18:25 
Thanks a lot for the resource and comment.
GeneralMy vote of 3memberBit_Flipper1 Jul '10 - 18:05 
Assembly is not as widely used in PC programs as it is in embedded systems. The author has not stated this fact to the readers.
GeneralPE File Formatmembermnjrupp29 Jun '10 - 4:50 
A good understanding of the "Portable Executable" file format is helpful for anyone who wants a better understanding of how an EXE or DLL works. I am interested in creating a vbscript compiler so understanding what is under the hood is a must.
 
Thanks again for the article.
 
http://en.wikipedia.org/wiki/Portable_Executable[^]
GeneralOveral costmemberdanielj29 Jun '10 - 3:58 
I do agree that writing code in assembly gives programmes the feeling that they have achieved something, but most companies would not like to see assembly code in their applications.
 
The reason being that the time to write and maintain assembly code is many orders greater than using high level languages, thus introducing spiralling costs.
Even writing something as simple as a simple Notepad type of application will take weeks.
I cannot think of an employer who would want to pay you per hour the same amount as someone who can produce the same application within hours using a high level language with more than adequate performance.
Not only is time money but also opportunity, and being able to provide features in the shortest possible time is as important.
 
Also I cannot thing of an employer who would rather see an application being maintainable by all developers than a special few.
 
I have found that most of the time that most of the performance problem is either as simple as something within an algorithm or as drastic as a need to change something within the architecture of the application to obtain better performance.
 
I have used assembly to obtain better performance, but would say that the benefit was not that great.
 
I do agree that knowing assembly language does give you more an academic advantage, as you would understand the underlining architecture, but would be careful to say it gives you an overall benefit.
GeneralRe: Overal costmemberbjames0229 Jun '10 - 4:43 
Thanks for the response.
 
I never said that assembly language was cost effective. I simply stated that we can benifit from learning a language that close to the machine.
 
Thanks

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web03 | 2.6.130523.1 | Last Updated 29 Jun 2010
Article Copyright 2010 by bjames02
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid