Assembly Language Introduction

An assembly language is an extremely low-level programming language that has a 1-to-1 correspondence to machine code — the series of binary instructions which move values in and out of registers in a CPU (or other microprocessor).

Introduction

A microprocessor is a mechanical calculator. It has a number of named registers, which are like holding pens for numbers. It receives instructions in the form of machine code, which is represented by a series of binary bits (1s and 0s). For example, here is a line of machine code:

10110000 01100001

The first few bits (10110) are an instruction to copy a value into a register. The next three digits (000) identify the register which the value will be copied into. The rest of it (01100001) is the value which is to be copied.

Of course 10110 is meaningless, and the computer doesn't "know" that it means "copy the value." The processor is designed so that the series of electrical impulses represented by 10110 (on-off-on-on-off) causes the desired result. This is part of what is meant by "mechanical."

Now if you're going to write a program for the processor to execute, you can imagine writing thousands of lines of 1s and 0s would be both tedious and error prone. The solution is assembly language. Assembly language provides human-understandable substitutions for long strings of binary code.

Example

For example, if 10110 means "move the value," then we could abbreviate it with the MOV command.

We could also give the 000 register a easier to remember name (in this case, the register is named AL).

Finally, we could render the value in a different numbering system, such as decimal (91) or hexidecimal (61). That line would then be MOV AL,61. Once a whole program is written this way, an assembler can easily translate each line into the appropriate binary representation.

Computers do work (perform calculations, move data, transform data), by processing billions of these tiny instructions per second.

Very simple instructions (move this value, copy that value, add these two values together and save the value over there) combine to form complex operations, which combine at higher and higher levels to actually do things you would recognize as meaningful.

Assembly Language Resources

Online Resources

Tutorials and Basic Guides

Video Tutorials

Reference

Tools

Assemblers — there are a lot of assemblers available — here are a few of the most popular free and open source assemblers:

IDEs (Integrated Development Environments):

  • SASM, Simple crossplatform IDE for NASM, MASM, GAS, FASM assembly languages

  • Fresh IDE, visual assembly language IDE with built-in FASM assembler

  • WinAsm Studio, a free IDE for developing 32-bit Windows and 16-bit DOS programs using the Assembler

  • Visual MASM.

Community and Ongoing Learning

Books

Should You Learn Assembly Language?

Whether you should learn assembly language depends on what your goals are. For most developers, the answer is "no."

There are two primary reasons to learn assembly language: because you want to use it directly, or because you want to understand computers at a fundamental level.

From a practical standpoint, only a relative handful of the world's engineers and computer scientists actually use assembly language.

The overwhelming majority of software development, including virtually all applications development of any kind, uses high level programming languages, and not assembly code. Some specific areas where assembly language gets used are:

  • Operating systems

  • Firmware

  • Device drivers

  • Language design

  • Compiler design

  • Embedded systems

  • Hardware design

  • Advanced cryptography

  • Theoretical computer science

The other reason to learn assembly language is just to gain a better understanding of what is actually going on deep in the guts of a computer. (This is why virtually all Computer Science majors have to learn assembly language.)

Of course, if you're the kind of person who is really interested in that, you might want to think about a career working in low-level systems development.

Other Things to Learn

There are some languages where, if you know just a little, you can do a whole lot. Python and Ruby are like that — you can learn enough in a weekend to build something worthwhile. Assembly language is not like that.

Assembly language is never used in a vacuum. The type of engineer who needs to know assembly is likely to be working in area where there is a need a to know a handful of other skills to be effective. These likely include:

  • Hardware languages, like VHDL and Verilog, along with a good understanding of microprocessors and electrical engineering

  • Low-level operating system languages like C and its derivatives: C++, C#, and D

  • Legacy languages like Fortran and Cobol

  • Platform languages like Java and Objective-C

  • Algorithms

  • Compiler, interpreter, and language design.


Further Reading and Resources

We have lots more information on this kind of stuff, Programming: Languages, Timeline & Guides.

What Code Should You Learn?

Confused about what programming language you should learn to code in? Check out our infographic, What Code Should You Learn?

It not only discusses different aspects of the languages, it answers important questions such as, "How much money will I make programming Java for a living?"