An instruction in computer science is the basic unit of work that a central processing unit or other computing engine carries out. It is defined by the processor's design and the processor's instruction set architecture (ISA). At run time, each instruction directs the hardware to perform a simple operation such as arithmetic, data movement, logical tests, or control transfer. Although the idea is straightforward, implementations differ widely in size, encoding, semantics, and how they interact with memory and registers.
Formats and sizes
Instruction length varies by architecture. Small microcontrollers sometimes use compact 4-bit or 8-bit encodings to save space and power; such designs are common in embedded systems and are associated with simple 4-bit and microcontroller families. Desktop, server, and scientific processors typically employ 16–64 bit instructions or variable-length encodings measured in bytes. Very long instruction word designs, known as VLIW architectures, pack multiple operations and operands into a single, wide instruction to express instruction-level parallelism explicitly.
Components of an instruction
Most instructions are built from a few common elements. An opcode field identifies the operation (for example, add, load, or branch). Operand specifiers indicate the sources and destinations; these may name registers, memory locations, or include immediate literal values (operands). Encodings often include fields or prefixes for addressing modes, register indices, condition codes, or data size. Some processors also use microprogramming, where visible instructions map to sequences of lower-level micro-operations implemented in microcode.
Addressing modes and operands
Addressing modes determine how an operand specifier should be interpreted. Common modes include register direct, immediate (literal), direct memory address, indirect (pointer), indexed, and relative addressing used by branches. The combination of opcodes and addressing modes controls expressiveness: complex instruction set computers can encode many addressing options in a single instruction, while reduced instruction set computers (RISC) favor simpler, fixed-length instructions that simplify decoding and pipelining.
Representation and toolchain
At the lowest level an instruction exists as machine code: a sequence of bits and bytes that the fetch/decode hardware reads from memory or instruction cache (machine code). Programmers rarely write machine code directly. Assembly language provides human-readable mnemonics and operands (assembly language), and high-level language compilers generate machine code automatically (compilers). The same abstract instruction concept can also be applied more generally to any element of an executable program that triggers computation.
Execution models and performance
How an instruction executes depends on the processor microarchitecture. Simple scalar cores fetch, decode, execute, and write back a few instructions per cycle. Superscalar designs dispatch multiple independent instructions in parallel, while VLIW relies on the compiler to schedule parallel operations into a single long instruction word. Pipelining breaks execution into stages to increase throughput, but introduces hazards (data, control, and structural) that require forwarding, stalling, or reordering to resolve. Modern high-performance processors also use out-of-order execution, speculative execution, and complex branch prediction to keep functional units busy.
History, uses, and important distinctions
Early computers exposed low-level instruction sets directly and often used microprogramming to simplify control logic. Over time the design space split into philosophies: CISC designs packed many capabilities into each instruction, while RISC simplified encodings for faster pipelines. Today the ISA remains a stable interface between software and hardware, but the microarchitecture implementing that ISA can change to improve energy efficiency and performance. Typical instruction examples include load/store, arithmetic (add, multiply), logical (and, or), shift/rotate, control flow (branch, call, return), and system or privileged operations used by operating systems.
Quick reference
- Common elements: opcode, operands, addressing mode, immediate data.
- Common execution features: pipelining, superscalar issue, out-of-order, speculation.
- Encoding styles: fixed-length (often RISC), variable-length (many CISC ISAs), VLIW (wide fixed bundles).
- Toolchain terms: assembly, compiler, machine code.
For further reading about architectures, processor design, and instruction encoding, see resources on processor fundamentals, RISC/CISC tradeoffs, and instruction set manuals provided by processor vendors. Additional introductory material covers microprogramming and advanced execution techniques such as branch prediction and out-of-order pipelines.
Related keywords and topics: personal computers, supercomputers, byte encoding, VLIW scheduling, RISC design, and microcontroller optimizations such as those found in small microcontrollers or minimal instruction sets like some 4-bit families.