Overview

Machine code, also called machine language or native code, is the form of a computer program that a processor can execute directly. It consists of a sequence of instructions encoded as numbers and bits. Each instruction tells the processor to perform a simple operation — for example load, store, add, compare or branch — using values stored in registers or memory. The exact meaning and encoding of instructions are set by the system's instruction set and the underlying computer architecture. Machine code is commonly represented in binary, and often displayed in hexadecimal for human readability; both binary and hex are ways to show the underlying binary patterns.

Structure and characteristics

At the basic level, every machine instruction has an operation code and zero or more operands. The operation code (opcode) selects which operation the processor should perform, while operands indicate registers, memory addresses or immediate data. Encodings vary by architecture: fixed-length instructions are common in some designs, while others use variable-length encodings to provide a larger or more flexible set of operations. The concepts below are widely applicable across designs.

  • Opcode: the numeric code that identifies the operation (opcode).
  • Operand(s): data or locations the opcode acts upon (operand).
  • Addressing modes: ways to specify where operands live, such as direct, indirect or indexed, often involving memory addresses.
  • Instruction set: the full catalog of available opcodes and formats defined for a computer.

History and development

Early electronic computers were programmed directly in machine code, often by flipping switches or using paper tape. To make programming practical, symbolic languages such as assembly were developed; assemblers translate assembly mnemonics into machine code. Later, higher-level languages and compilers allowed developers to write in more abstract forms, but ultimately those languages must be translated into machine code so the hardware can execute them. Tools that translate or transform programs into machine code include assemblers, compilers and linkers — collectively part of what are sometimes called program builders. Assembly remains useful for low-level tasks and performance-critical code even today (assembly).

Uses and examples

Machine code is essential because it is the only representation a CPU executes. Common workflows include:

  • Compilers converting high-level language source into machine code so applications can run natively on a target processor.
  • Interpreters and virtual machines translating or JIT-compiling bytecode into machine code at runtime.
  • Firmware and bootloaders distributed as machine code images that initialize hardware at power-up.

Because machine code is tied to an architecture's instruction set, binaries are generally not portable between different processor families without recompilation or translation.

Notable distinctions and practical considerations

Machine code differs from higher-level program representations in several important ways. It is deterministic and low-level: the relation between instruction bits and hardware actions is direct and precise. This allows fine-grained control over hardware and performance tuning but makes programs harder to read, maintain and port. Some CPUs use microcode internally to implement complex instructions; microcode itself is another low-level layer beneath the machine-code abstraction. When software is described as "native code," it usually means machine code compiled to run directly on the target processor rather than run through an emulator or interpreter.

For further technical references about specific instruction sets, encoding formats and tools, consult architecture manuals and toolchain documentation: see links for instruction set, architecture, representations like binary and the broader software ecosystem. Practical resources include pages on opcodes, operands, addressing and memory (addresses), general computer structure, assembly programming, and toolchains and program builders.