Menu

Low and High Level Languages

Assembly Language

Assembly language belongs to the low-level group of languages, sitting just above raw machine code. Rather than typing rows of 1s and 0s, you write short codes called mnemonics, each of which stands for an instruction the processor can carry out. That keeps you close to the hardware while making the code far easier to read, write and remember than binary.

Mnemonics map to single instructions

A mnemonic is a short, human-readable label for one machine-code instruction. For example, MOV might mean "move a value into a register" and CMP "compare two values". You can guess what each line does from its mnemonic, which is impossible with a line of binary.

The match is close to one-to-one: each line of assembly language usually becomes exactly one machine-code, or CPU, instruction.

Assembly lineWhat it tells the processorAfter translation
MOV R3, 5put the value 5 into register 3one machine-code instruction
CMP R3, R4compare the values in registers 3 and 4one machine-code instruction

Written for one processor

Assembly language is processor-specific. The mnemonics available, the registers and the way values are handled all belong to one processor family or architecture, so a program written for one chip will not run on a different one. Assembly code is therefore not portable: moving it to another processor means rewriting it.

Translated before it runs

A program written in assembly language cannot be executed as it stands. An assembler translates it into machine code first, turning each mnemonic into the matching binary pattern. The mnemonics are there to help you; the processor still needs the binary.

Assembly language also lets you work with the hardware directly. You can name a memory location and store a value in it, read and change the contents of a register, or send signals to hardware features yourself, rather than leaving it to a high-level language's translator to manage memory for you.

Practise this