Machine Code

Machine code is the lowest-level form of a program: a sequence of binary instructions that a processor’s hardware fetches from memory and carries out directly, with no further translation. Each instruction is just a pattern of bits. Some of those bits form the opcode, which says what operation to perform (add, load, jump, compare), and the rest form the operands, which say what to operate on, whether a register, a constant value, or a memory address. The CPU has no notion of variables, functions, or types; it only sees these encoded instructions and executes them one after another.

This is the layer that sits directly beneath assembly language. Assembly is a human-readable shorthand in which a mnemonic like MOV or ADD stands for a particular machine instruction, but the two are nearly one-to-one: an assembler’s job is to translate each assembly line into the exact bits the chip expects. When a compiler turns C or Rust into a runnable program, the final output is machine code in this same binary form. Bytecode, by contrast, targets a virtual machine rather than a physical CPU, which is why it needs an interpreter or just-in-time compiler before real hardware can run it.

The precise encoding of machine code is defined by a processor’s architecture and published in the vendor’s architecture manual. Intel’s “Intel 64 and IA-32 Architectures Software Developer’s Manual” devotes an entire volume to the instruction set reference, describing, instruction by instruction, the opcode bytes, the operand-encoding rules, and the exact bit layout the silicon decodes. Volume 2 of that set “includes the full instruction set reference, A-Z,” and “describes the format of the instruction” for every operation the processor understands. A different architecture, such as ARM or RISC-V, encodes the same conceptual operations with entirely different bit patterns, which is why a machine-code program built for one will not run on the other.

Because the encoding is machine-specific, machine code is the least portable representation of a program and historically the most painful to write by hand. Early programmers did enter raw numeric opcodes directly, toggling them into memory; assembly language was the first abstraction layer built to spare humans that tedium, and high-level languages and compilers followed. Yet every one of those abstractions eventually bottoms out here. Whatever language a program is written in, the work the computer actually does is the execution of machine code.

Understanding machine code clarifies what a CPU really is: a machine that does nothing but repeatedly read an encoded instruction, decode its opcode and operands, and act. The von Neumann idea of a stored program means those instructions live in the same memory as data, indistinguishable as bits until the processor fetches them as instructions. Everything from an operating system kernel to a web browser is, at the moment of execution, a long stream of these binary commands flowing through the processor.