Please explain/exemplify your answers. If yes, what architecture do you recommend to get started with?

+1  A: 

Learning is always worth the effort. Learning assembler enables you to better understand low-level optimizations. Moreover, it allows for understanding the complexity of your application.

Having said that, assembler knowledge will rarely come into today's high level programming practice.

If you want to learn assembly, i would suggest going over the principles and not focus on a specific architecture and all of its instructions.

Shimi Bandiel

I think learning assembly language is an important part of really understanding your computer. I think it is worth the effort. Assembly language is very easy, but writing programms in assembly language isn't. You might want to read The Art of Computer Programming by Donald E. Knuth. It's the best book series I ever read!


If you are student then start with 8051 or ARM.

If you are professional then start with ARM or 8086.

+11  A: 

Unfortunately there is no definitive answer.

If you're writing big business applications (some call them "enterprise", but it may have negative connotations) then of course not.

However, when involved with operating systems, low-level C stuff, compilers, hypervisors, language VMs (like JVM, or V8) or even other stuff reasonably close to the machine, it's nice to know how the CPU is doing job internally.

There is also a third choice. I had a course on university called basically "Architecture of a computer" which didn't teach you assembler, but how does CPU operate, how extensions like MMX, SSE, etc. work, what's good and fast in low level perspective and what's not, etc. Memory latency, disk latency, caches on the way... you can gain many advantages of learning assembly by learning these things.

For the rest, you would have to see for yourself. You asked about architecture... Well, I would say x86. Most popular. ;-P

Your third choice is a very good point. I did a similar course at college and learned a lot. The textbook, "Computer Architecture: a Quantitative Approach", was excellent.
Daniel James
The fact that IBM still provides turn key Bussiness solutions would lead me to believe that there is still room for technical excellence in big business applications that address core Computer Science topics.
+1  A: 

If you are/will be working with other close-to-hardware languages and techniques (read: C/C++), then absolutely, Yes.

Mostly this pays off when you're debugging. Some problems (this even happens in GUI code) are just too wicked to be found by other means than looking at how compiler understood your code and tracking back from there.

Other than that, it is "just" worth learning. In the same way as Lisp is: it will give you another useful perspective on things.

Vytautas Shaltenis

Yes. It helps you to understand in details how the machine works in the very low level. Also then when you use high-level language like Java and C++ you have in mind what is "under" the code, at machine instruction level, which helps you to optimize the code for CPU, memory e.t.c. I would suggest to start with Motorolla 68000, because it has relatively small number of instructions which is perfect for understanding the principles. Then you can compare with x86 and then advance to something more modern if you are still interested :)


No, unless you have a specific need (ie, embedded programming, etc.).

Bertrand Meyer called the C language "portable assembly". I tend to agree with him, and think that learning C will get you close enough to the metal to gain an understanding of what you're program is really doing. The extra effort to learn assembly language won't provide enough benefit in terms of making you a better programmer to justify the effort. Learn C, and then use the time you would have spent on Assembly Language to learn how DB internals really work.

Unless you are interested in embedded programming. Then you'll want to learn assembly for the microcontroller you are most interested in.

John Stauffer
+1  A: 

It depends on what you plan for your future and what you like to program.

On modern CPUs there are very much possibilities to improve program performance, which I think are to complex to learn, and current compilers do a pretty good job on optimizing code for specific CPU types.

However learning assembly might help you to get a better understandig of the used CPU, which might be a good idea to learn programming on small embedded CPUs (like the AVR architecture, or PICs). However even on these embedded systems modern (C) compilers do a pretty good job, so that in the most cases you will not get any better performance when you use assembly.

On the other side the assembly language is a nice low level programming concept which might help you get a different perspective to computer programming problems.

If you decide to learn the assembly language the architecture you choose depends mostly on your plans what you want to realise. But it might be a good idea to choose an architecture which has a good simulator or at least realtime debugging interface, so that you can see what your code does (and so that you can see the contents of the used processor registers).

+1  A: 

For embedded software development on uProcessors and DSPs assembly language is still widely used, e.g. to speed up certain tasks with inline assembly (instruction within C code) or on some targets because a C compiler is just not available.

Also, when using a JTAG debugger you can step through the instructions on an assembly level. Only there you can determine whether some tasks are atomic, i.e. use only one instruction (e.g. Variable++) or need to be protected against preemption by other interrupts.

In these situations in comes in very handy to be able to understand assembly language. For the target specific instructions (where there are plenty of usually) you always have to the reference manual of the processor/cross-compiler, but the basic principles of assembly language should still apply.

To get started you can use the assembler included in the GNU compiler set.


It entirely depends on your circumstances.

If you are building webpages, it is a clear no. If you are doing some very low level stuff, then perhaps.

Is it worth learning assembly just for fun? No. It's a language geared towards computers, not humans. Want to learn more about the the depths of programming? See Should I learn C?


Not unless you want to write your own compiler, or want to assist with a compilers development, or optimize code that compilers can't yet optimize. GCC & Intel work hard at making their compilers produce the fastest code from the higher-level languages, and probably have more ways around common design pitfalls that the average coder.

Its more productive to code in a higher-level languages, that way you're spending more time solving the problem inside the problem domain, not worrying about trivialities that just slow you down.

Assembly is only really of use once you have designed your project in a higher level language, and have determined there are bottlenecks in the code that can't be solved any other way.

Kent Fredric

I would have to say no, except maybe for fun. The entire idea behind using a programming language is to abstract away the bare metal and allow the programmer to express his/her ideas efficiently. Assembly language is only barely more expressive than machine code.

When I was younger I had great fun writing tiny programs in Assembler. (Mastering Turbo Assembler is one of my favorite computer books ever.) It's not useful though.


Is it just for personal interest? Are you already an experienced programmer?

I'm not sure making it your first or even your primary language makes sense.

If you want a deeper understanding of how all languages work, it's a great idea. It would be like an English speaker learning Latin, you better understand the roots of the language, and therefor understand the language better.

Get "expert" at your language of choice first.

Dan Williams

I have some anecdotal evidence on the subject, although I am not sure which answer it supports :-) Here it is:

Several years ago I compiled an implementation of the blowfish encryption algorithm using gcc. The source code contained something like a = b << 21 | b>> 11, commented "this is a 11-bit cyclic shift, speed it up by replacing with the appropriate assembly instruction for your architecture". I did that (using gcc inline assembly), but my version didn't run any faster. The reason was that gcc had found the optimization by itself and generated the appropriate ror opcode.

Rafał Dowgird

Depends on what you are working. I suppose it can be worth the effort for the organisational skill you will have to learn. Architecturing your assembly code so that you can actually understand what you just wrote is something that can be valuable for any language.

To start with assembly, I would go with a RISC architecture, because R in RISC means Reduced. With a Reduced Instruction Set, you can memorize quite rapidly the various token.

Another very interesting point is that it learns you how a processor really work. The ARM reference technical manual (I have to lookup the exact name) is a great technical book. I mean you can read a lots of the chapter in it, and learn a lot of thing about interruption, stack, register and so on.

I only ever had to write assembly to write very concise code for first stage bootloader, but as soon as you can switch to C, you should do so.

+2  A: 

I would recommend reading documentation for several architectures.


  • it gives you fresh perspective on what's happening in your computer;
  • it may give some new ideas for your coding process;
  • it's fun to read: some parts are engineered by extremely smart people solving very challenging problems.

As for the architectures:

Actually writing something in any of those assemblers is entirely optional, in my opinion. Most probably you won't write anything useful or entertaining in pure assembler anyway.

Hope it helps,

+1  A: 

It depends on where you're going and what you're trying to accomplish.

If you'll be developing interactive applications (or web applications) in high-level/scripting languages like Java or Python, then definetly not. Knowing assembler won't make your applications that much better.

Christian Davén

Programming in assembly will help most programmers to get organized. It is so easy to get lost that one has to create good habits of programming. Write small meaningful routines is one of them.

I agree with other comments, it helps with the understanding of computers and software.

+2  A: 

The usual answer is that learning assembly language is good because it gives you a deeper understanding of what's really happening on your computer. It might give you some insight into why certain high-level language constructs are fast, or slow, or consume huge amounts of memory.

Personally I'd recommend assembly language programming because it can be fun. In particular I'd go for a very small and simple architecture, with good access to hardware. A good example would be any of the small, cheap microcontrollers. My personal experience has mostly been with Microchips PICs, but there are lots of others

It can be a real challenge to fit something into the tiny amount of program memory on some of these devices; the older devices only had 128 program words available. Using these devices also lets you play with hardware, there's can be a lot of satisfaction to be had from just making some lights flash.

The more advanced microcontrollers have USB or even ethernet, so you can play about with making peripherals. Starter kits are usually available quite cheaply and the developments tools (assembler and simple IDEs) are usually free.

Kevin ORourke
I learned 6502 assembly on my apple II back in the day. Learned it again on m68k when I was a better programmer. Never use it, but happy I know it because it **does** inform your higer level thinking.
+1  A: 

It depends on what your goal is.

Writing in assembly is generally not a good idea, because it is not portable at all, and it's a nightmare to maintain.

Why would you want to learn Assembly Language?

  • If you are working on a compiler for a specific platform
  • If you are writing a low level driver that requires very specific assembly instructions
  • If you require very fast code
  • If you do require specific timing (for example when you code for an embedded environment and you are not using an operating system)
  • If you are writing an operating system
  • You have to maintain legacy assembly code

Even in the case where some of the above conditions are true, you would normally only do the specific part of the code in an asm{ } block and the rest in you compiler of choice. C, for example does have the asm { } construct (Java would, of course, not have it.)


Yes, it's worth learning an assembly language (or a few, even). I'd suggest MIPS64 or 68000 because they're interesting and simpler than x86 (MIPS64 certainly seems more expressive), but on the other hand you probably have an x86 machine and there's nothing like seeing an assembly program you wrote running on your own (real) machine.

Why? Not only will it teach you a lot about low-level architecture and lots of things we take for granted most of the time (like accepting a number as input from the user!), it'll show you that you have the power to do anything you want with your machine. That operating systems don't have any special magic you yourself don't have now - indeed, you could write a bootloader (like LILO/GRUB) on floppy/CD/USB key that prints some stuff, takes input from the user and crashes or something.

If you have some old machine lying around (like my old Atari ST and Falcon upstairs, or my younger Palm PDAs) you could program it in its native assembly language.

So in summary, do it for the knowledge, but also do it because it's tremendously empowering.

+1  A: 

If you work in the electronic industry o( on embedded systems) then yes definitively.

Assembler is almost required to understand how microcontrollers can be programmed. Of course, many microcontrollers comes now with IDE and C-like environments (Microchip has one for their PICs, ImageCraft has one for HC08 Freescale mcu ...).

When dealing with MCU, assembly is useful to understand the exact interactions and consequences of your code. A wrong bit here and a pin there could be in the wrong logical state, hence in the wrong electrical state leading to the device malfunction.

Additionaly, knowing assembly let you learn about memory usage (I learned that a for loop can take more spaces than repeating 4 times the same statement).

Microchip PIC18 family is easy to start with in such case.


Oddly enough I've just asked myself the same question when I started learning what assembly language is and what it does (as of last week).

When learning Assembly Language, you are (along side learning the languages itself) learning how the processor works in conjunction with the rest of the computer.

If programming low level programs (in machine language; Binary, Hex), you will really need to learn how processors work. Virtual Machines need low level programming in order to emulate the processor, so if you're going to program VMs, then low level would probably be a really good thing to learn. However, if the field you want to go into requires you to have knowledge of High Level (C++, Java?) then knowing low level would we worthwhile to learn, as you'll be learning how to think in efficient code writing.

I'm probably missing out a lot here, but that's because I just started myself.

If you want examples, then looks at Squadette's post, which provides some examples from Intel and AMD

Confused Computer Guy

If you DO choose to learn assembly, I'd argue that the best way to start would be to write code in C, compile it, and then run gdb on the result. you can disassemble particular functions (disas func4), check the state of registers (info registers) etc.

That said, you may want to drop the optimization level some so that you can understand it.

Which brings me to my main point, learning Assembly for optimization reasons is largely a waste of time. GCC and other C compilers will almost always optimize circles around you. And these optimizations won't break anything. (This whole paragraph can be attributed to my 213 prof's (Randy Bryant) lecture yesterday; I opted to tone the message down a bit, because we're all friends here :) )

Alex Gartrell
+7  A: 

Learning assembly was something I've never regreted although I haven't directly used it in years and don't plan to either.

May I put it like this , learning assembly is about as important as learning lisp or haskell. Unless you are in a very specialized field they are not going to be something you actually use, but they'll make you a better programmer for it.

I can program in Assembly and C. I've tried to learn Haskell or LISP and I don't see how they could make a better programmer (Improve my C and Assembly, that's what I use).Assembly however was truly a teaching experience.
+4  A: 

It's often said that, in order to debug effectively, you need an understanding of what's going on at one level lower than the code you've written. If you're trying to debug a C program and you're faced with the x86 assembly output, how are you going to understand that unless you've learned x86 assembly?

I tinker with Nintendo DS coding, which is much closer to embedded development than it is to desktop coding, and I've started learning ARM asm in order to debug faster and optimise code. ARM is actually a pretty good language to learn, as it still is very relevant and a useful skill if you ever want to get into embedded work.

Calling C "portable assembly" really ignores just how much work C does to abstract the complexities of assembly away. Really simple things that you take for granted suddenly become massively complicated. How would you allocate memory on the heap if you didn't have malloc(), or even a pre-allocated memory area designated as the heap? How would you free it again? How do you add two 16-bit numbers together if (as on the MOS6502) you've only got three 8-bit registers and an 8-bit CPU? How does C prevent the CPU registers being clobbered when you call a function?

Most of the time you won't need assembly, but it'll definitely teach you more about how things work below the surface.

I would add them together 8 bits at a time :D
Don't forget to check the carry flag, though.

I did alright in Java. I hated C++ because I never truly understood what the pointers were doing. THEN I took Assembly. The pointers then made sense! I actually started to enjoy programming once I learned assembly. I very much recommend learning it so you understand more of the basics of how the computer works. It was a real eye-opener for me!


It can do some pretty cool stuff, but I wouldn't say it's worth it anymore. The only exception would be if you work in a shop that needs someone to maintain it, then you may become a very valuable person. I was told all through college that Cobol was dead, mainframes were dead.. Now, it's almost ten years later and I've been a mainframer since I got out of school, and no end in sight.


In university, I had a course in 68k assembly in first year. We wrote extremely simple programs that complemented our "Introduction to Programming" course in Java and which allowed us to play with low level concepts like learning about addressing and low-level data representation. In second year, we built a small 68k board by wire-wrapping and used the 68k skills from 1st year to write a really simple "operating system" for it.

I haven't worked that close to the machine since, but the experience of doing those courses has undoubtedly made me a better coder. It filled the gap between hardware and high-level programming and definitely made C++ make a lot more sense. ;)

I would advise you to learn assembly to improve the depth of your technical knowledge. If you never envisage using it professionally, just pick the easiest architecture you can find and play with that. Getting your head around the concepts used at that level of abstraction is much more important than the language itself. Once you start getting bored, get a reference for another architecture and compare how that architecture does things or write a small, simple virtual machine and play with that or pull up the source code for a free operating system and see how it interacts with the machine. Just jump in and let your curiosity guide you.

Conor McDermottroe

Only if you don't plan using it ;-)

It's not bad to know assembly, as it will teach you how the CPU actually works (often not as newbie expects it to work) and it will teach you what kind of instructions an interpreter or compiler has to generate form your code (which will give you some insight, why certain code runs faster than other code).

However, if you plan to actually use assembly language nowadays, you are doing something wrong. If you are a Linux kernel core developer trying to implement better IRQ handling for PCIe cards, that may count as an excuse, but in most other cases, everything that assembler can do can be done in high level programming language as well, and not necessarily slower (GCC generated machine code will most likely beat any hand optimized assembly code a newbie produces).

I know PPC and x86 assembly (both Intel and AT&T style notation). If you want a tip from me: I personally think PPC assembly is much more complicated, even though it has less instructions than most x86 CPUs. And even though AT&T style notation is much more logically, it's harder to read IMHO. I'd get a book about 386 Intel assembly programming and start with that. Even the latest Intel CPU still supports all these instructions (just a lot more got added, but you already get pretty far with 386 assembly only).


To answer the question of whether it is worth learning assembly, is subject to where you are in life. I found it beneficial to learn assembly when I was working on a Commodore 64, trying to take advantage of the various capabilities that were mapped out in a book called, "Mapping the C64". I later moved on to a PC and used Borland's Turbo C++ to try to write my own graphic's library in C and assembler - I wanted to have the same "Sprites" capabilities that the C64 had, to use in my C programming projects. That was during my teen-age years.

You have to have a innate need to know more about what goes on "behind the scenes" of a computer's inner workings, and the workings of the software that runs on one, to maintain an interest in assembler. The best reason to learn assembler would be to fulfill this need to learn more about the core of what runs all the software we use today. Another reason might be to improve the performance of a C function that isn't running fast enough or lacks capabilities that you need.

The worth of learning assembler may not translate well into material gains, especially when there are so many high level languages that build assembler code, built on the shoulders of knowledge of the thousands who have coded it before us. Also, you should consider that PC's are able to run the most inefficient assembly code, much faster than ever before, so there may be little sense in re-writing such code, unless you're working for NASA and there's a need for high speed, real-time decision making code embedded into the chips used in a rocket, a space probe, or radio-signal receiver/transmitter. I would learn assembler for personal satisfaction, but not do so as a sole career choice, unless of course you truly feel that its your calling in life - then go for it.


Most modern processors comes with a parallelized vector instruction set. If you ever need to write optimized vector routines, then no compiler would understand your intentions from high level code and generate vector instructions. (You shouldn't consider compiler intrinsic instructions high level). But there are plenty of libraries which have done the hard work for you though.

+1  A: 

If you work with compiled languages you should at least learn it up to the point that you can read and understand small pieces of asm code. Just enough that you can put your source-code and the disassembly side by side and find out which instruction group belongs to which part of the code.

It becomes very usefull when you debug programs. It can save you days of frustration if a program misbehaves and you can't find a cause in your code. In C/C++ that happends quite ofthen if you do things like violating an aliasing rule or if you write code that depends on integer overflow behaviour.

It does not take that long. Assembly is so simple that you can learn the basics over a weekend or two.

Writing applications in assembly is insane, and it rarely helps to rewrite time-critical routines in assembly these days unless you're working in the embedded field.

Nils Pipenbrinck
+53  A: 

Do you have any interest in effectively using a debugger? Then yes. Do you have any interest in writing reliable or efficient code? Then yes. Even if you never actually write assembler, once you learn assembler on one platform then all other assembly languages and all other programming languages are simply a matter of syntax.

Since you cant find a PDP11 around anymore I highly recommend the msp430 as a first platform. Second perhaps by ARM, both because it has a good ISA and because everything not a desktop has an ARM in it. And because if you choose you can have a good, long, successful career by simply knowing ARM assembler...

I recommend the best way to learn assembler is to write a disassembler. Take an assembler, and if possible a perfectly good disassembler, assemble simple adds and moves and such to a binary format (is probably going to be intel hex or srecord or elf, parsing of which is yet another good programming exercise)(of course are those really "binary" formats?). Dont write the disassembler with the intention to publish or sell, just for your own purposes, this will keep you focused on the task at hand. By doing this you will be forced to learn every instruction and every nuance of every instruction and learn how to get the assembler to create every nuance of every instruction thereby making you more knowledgable than most assembly programmers for that platform.

ARM in ARM mode (ARM7 aka armv4) is a very good place to start disassembling because the instructions are all 32 bits on 32 bit boundaries. Fixed size and aligned instructions. If you start with say the x86 you will very quickly fail, variable size instructions are difficult at best to disassemble, you cant just start at the top and run through the binary in a linear fashion, you instead have to simulate execution, start at the reset point and follow all of the possible execution paths, and even there you will fail. Disassembly on a variable sized instruction set is a very advanced topic. (for learning purposes you can still write a disassembler and only write two or three instruction programs with no data structures embedded in the instruction sequence).

After writing one or two disassemblers, each nth disassembler and instruction set should only take you an evening or two to learn. Go learn a few different architectures. Decide if you like risc over cisc and why. Realize that the x86 architecture is horrible at best, how could it have won?

Next, write some simple C code, using yours or the compilers disassembler examine how your high level programming style is implemented on the hardware. Realize that the number one performance improvement is your compiler not your style. Few of the many programmers that dont know assembly and have not done this exercise really understand that the same exact source code can execute at many different speeds from each brand of compiler and some brands of compilers produce much better code than others. So re-arranging your high level code and changing your programming style to make the compiler more likely to produce good code is one thing. Getting it to do it is another. You will learn all of these things with this exercise.

If you want to be a successful software engineer, be able to choose the jobs you work on and not get stuck with cleaning up leftovers, you have to not only learn assembler but learn how different compilers turn different high level languages into assembler for different platforms. You never have to be an assembly programmer to do this, you only have to understand the process and the results.

Michael Abrash may have already been mentioned, find a copy of The Zen of Assembly language. It was reprinted in the black book perhaps, even at the time original copies were hard to find, I was lucky to have bought one not knowing it would be a rare gem. Even if you learn x86, or other assembler, finding out that you can increase performance by orders of magnitude by simply re-arranging the same instructions or similar instructions is humbling. Actually all of his books and his magazine articles if still available are all gems.

+1 "Realize that the x86 architecture is horrible at best, how could it have won?" It's a clear example of popularity vs technical merit. I've seen references that said IBM considered 68000, but decided it costed too much. Once the IBM "Clone Wars" began all the other personal computers were doomed, including notably the Amiga which was well ahead of it's time. Steve Jobs turned out to be the Obi Wan of the 80's personal computer era.
"once you learn assembler on one platform then ... all other programming languages are simply a matter of syntax" Hardly. Even In C# it's getting hard to map it to ASM, let alone Python or Haskell
I'll play devil's advocate. Given that I never see assembly today, even in my debugger, that performance today is about algorithms and data structures, not opcode bumming, and that even knowing half a dozen assembly languages, I can't figure out x86 on my own computer, why should one learn assembly, except as intellectual curiosity? Every answer I've seen (here or elsewhere) is generic enough that it could be used as justification for learning microcode, logic gates, MOSFETs, etc., yet nobody seems to claim that good programmers need to know all that. Why draw the line here?
It is not always case of mapping from a high level languages directly to the asm. It is also about the problem solving aspects, breaking the problem down into small digestible steps and attacking those. Programming becomes all about learning the syntax at that point.
+1 for "the best way to learn assembler is to write a disassembler."

definitely yes! I'd a brush with assembly language during my masters. It is really fun to know how all the stuff like x++ or if(true == ???) is executed by machine. As you have to think in terms of registers and stacks you get very close view of the real hardware works.

I think x86 is good thing to start with. You can use nasm assembler. There is a really good book by Peter Able but you will have to use Microsoft assembler with it.

+1  A: 

Learn to read assembly! It helps your debugging skills, and you will be able to analyze crash-dumps more efficiently.


At least read this "Under the Hood" article: http://www.microsoft.com/msj/0298/hood0298.aspx

Nemanja Trifunovic

In short, yes. Understanding assembly will make you understand the output from a C compiler. You get a better handle on what the computer is actually doing at a very low-level. This helps you write faster and more robust software.

+2  A: 

Assembly language is the Latin of programming. If you're a linguist, and know Latin, many modern Romance languages are comprehensible - you know the basics, you know roughly how they work. Assembly language (and the kind of programs you write) gives you the same fundamental comprehension of a computer - what is code, what is data, how do you change an execution path, how do you synchronise between threads - what are the building blocks used by everything that runs on your computer - even CSS.

Jane Sales
Latins is a "Dead Language" assembly is still evolving. And there are EXTREMELY different dialects of it, which have dramatic implications for the implementation of program language on top of it. VLWI pushes ALOT of responsability back to the compiler.

Absolutely. If you haven't debugged assembly, you haven't debugged enough. Take a quick look at Assembly And The Art Of Debugging and see what you are missing.


I think assembly language is something that one should learn while understanding the internal workings of a computer's registers and data flow. Otherwise merely learning the syntax wouldn't benefit enough.

title   Stack Overflow Response Program                             (negative.asm)
; This program displays "No!"

.model small
.stack 100h

answer_message db 'No!',0dh,0ah,'$'

main  proc
      mov    ax,@data
      mov    ds,ax

      mov    ah,9
      mov    dx,offset answer_message
      int    21h

      mov    ax,4C00h
      int    21h
main  endp
end   main

Yes, it is. You learn how stuff REALLY works and become a better high level language developer that way. I really encourage you to learn assembler. :-)

Turing Complete
+1  A: 

MMIX designed by Donald Knuth to be educational computer.

Dennis Yurichev