Finding something worth knowing…

Technology

Assembly language speaks almost directly to the processor, one instruction at a time

Beneath every app sits machine code, raw numbers a processor understands. Assembly language is the thinnest human-readable layer over those numbers, usually one written line per machine instruction. Early programmers wrote whole systems this way, and even today a small slice of the Linux kernel is still written in it for speed and direct hardware control.

Instead of numeric operation codes, assembly uses short memorable abbreviations called mnemonics, plus names for memory locations, registers and constants. A utility called an assembler translates the text into executable machine code and works out addresses automatically, sparing programmers tedious arithmetic and manual fixes whenever code changes. Because each language mirrors a specific processor's instructions, assembly written for x86 chips will not run on ARM ones. Even on one chip the notation can differ: Intel syntax and the AT&T style used by the GNU Assembler look quite unlike each other yet produce the same numbers.

The earliest example of a language standing in for machine instructions appears in Coding for A.R.C., a 1947 work by Andrew Donald Booth and Kathleen Britten. The word assembler is usually credited to Wilkes, Wheeler and Gill in a 1951 book, though they meant a program that stitched several sections into one. Assemblers became common in the 1950s, a step above bare machine language and before Fortran, COBOL and Lisp arrived.

Hardware limits shaped the tools. Many early assemblers read the source only once, because a second pass could mean rewinding a tape or feeding a deck of punched cards through again. A one-pass assembler meeting a label it has not yet seen leaves notes for later patching, while multi-pass designs build a full table of symbols first. Once computers gained big memories and disc storage, rereading became painless.

Over time most programming moved to higher-level languages. Fred Brooks, in his essay No Silver Bullet, said observers credited that shift with at least a fivefold jump in productivity, along with gains in reliability and clarity. Still, assembly lingers where it matters: in version 4.9 of the Linux kernel just under 2 percent of the source was assembly, while more than 97 percent was C.

Source: Assembly language

Related

More in Technology · All topics