What Is Machine Code?
Machine code, also called machine language, is the binary instructions a processor executes directly. Each instruction is a short sequence of bytes, such as b8 01 00 00 00, that tells the CPU to move, add, compare or jump, and every processor family has its own set.
Updated November 16, 2026
This program looks at three of its own instructions, the ones under sample:, and prints the bytes the processor sees. Press Run:
b8 01 00 00 00 bf 01 00 00 00 0f 05
Those twelve bytes are the machine code for the three lines under sample:, written in hexadecimal, two digits per byte. In memory they are bits: b8 is 10111000. The program never runs them. It reads them the way it would read any other data, because to the computer, instructions are just bytes in memory.
Reading the bytes
| Bytes | Assembly | What the processor does |
|---|---|---|
b8 01 00 00 00 | mov rax, 1 | Put the 32-bit number 1 in eax, which also clears the upper half of rax |
bf 01 00 00 00 | mov rdi, 1 | The same, into edi |
0f 05 | syscall | Call the operating system |
In the first two instructions, the first byte is the opcode, the part that says what to do. Here b8 to bf all mean "put the next 4 bytes in a register", and the register is chosen by how far the opcode is from b8: eax is register 0, so its opcode is b8, and edi is register 7, so its opcode is b8 + 7, which is bf. Not every x86-64 instruction is built this simply: some start with a prefix byte, such as the 48 in front of many 64-bit instructions, and some opcodes take two bytes, like 0f 05.
The 4 bytes that follow hold the number 1, but backwards: 01 00 00 00. x86-64 is little-endian, which means a multi-byte number is stored with its lowest byte first. The number 258 would be 02 01 00 00.
The assembler also made a choice here. The source said mov rax, 1, a 64-bit register, but NASM wrote the 5-byte instruction for eax, because writing a 32-bit register sets the upper 32 bits to zero and the result is the same. The long form, 48 c7 c0 01 00 00 00, would be 7 bytes.
How the processor runs machine code
The processor keeps the address of the next instruction in a special register, rip on x86-64, called the instruction pointer or program counter. It repeats three steps billions of times a second:
- Fetch. Read the bytes at the address in
rip. - Decode. Work out which instruction they are and how long it is. x86-64 instructions are 1 to 15 bytes long, so the processor has to read the first bytes to know where the instruction ends. ARM64 instructions are always 4 bytes.
- Execute. Carry it out, then move
ripto the next instruction, or to another address if the instruction was a jump.
Nothing tells the processor whether the bytes at rip were meant to be instructions. If a bug sends it to an address full of text, it decodes the text as instructions and runs them, or stops with an illegal instruction error. Modern operating systems mark data memory as not executable, so jumping into it ends the program instead; on Linux that is reported as a segmentation fault.
Machine code vs assembly language
Assembly language is the text form of machine code. The two map almost one to one, but they are not the same thing:
| Machine code | Assembly language | |
|---|---|---|
| What it is | Bytes the processor executes | Text a person writes |
| Example | bf 01 00 00 00 | mov rdi, 1 |
| Read by | The processor | An assembler, such as NASM |
| Labels and comments | None, only addresses | _start:, ; comment |
| Data in the source | Just more bytes | Directives such as db "Hello" |
| Tied to one processor family | Yes | Yes |
An assembler goes from the right column to the left one. A disassembler, such as objdump -d, goes back: it turns bytes into assembly. Comments are never stored in machine code, so they are gone. Label names survive only in the file's symbol table: on the program above, objdump shows the loop's jnz as jne 401019 <next_byte> (two names for the same instruction), and after strip removes the symbols, just jne 0x401019. This is how people read programs they have no source code for.
Machine code vs bytecode
Not every compiled program is machine code. A compiler for C, C++, Go or Rust produces machine code for one processor. Java compiles to bytecode in .class files, and Python compiles your code to bytecode before its interpreter runs it. Bytecode has instructions too, but they are for a virtual machine, a program, not for a physical chip.
That is why one .class file runs on any computer with a Java runtime environment, while a compiled C program has to be built again for each processor and operating system. The two meet in just-in-time (JIT) compilers: the JVM and JavaScript engines such as V8 turn the most used bytecode into machine code while the program runs.
Why machine code only runs on one kind of computer
Three things have to match before a program's machine code can run:
- The instruction set. x86-64 and ARM64 use different bytes for different operations. Apple's Rosetta 2 lets Macs with Apple silicon run x86-64 programs by translating their machine code into ARM64 machine code.
- The file format. Linux uses ELF files, Windows uses PE (
.exe), and macOS uses Mach-O. Each tells the operating system where the code and data are and where to start. - The system calls. The example above asks Linux for system call 1, write. Windows and macOS number their services differently, so the same bytes would ask for something else, or nothing.
Where to go next
Change the instructions under sample: in the Assembly playground and run the program again to see their bytes: try add rax, rbx or ret. The assembly language page explains the language those instructions are written in, the Assembly cheat sheet lists the common instructions, and the free Assembly course teaches x86-64 from the first system call. For how bits and bytes store everything else, see the byte page.
Frequently Asked Questions
Is machine code just 0s and 1s?
b8 01 00 00 00.What is the difference between machine code and assembly language?
mov instead of numbers such as b8, plus labels and comments for people. An assembler translates assembly into machine code, and a disassembler translates it back, although labels and comments are lost on the way.Is machine code the same on every computer?
0f 05 mean syscall on x86-64, while an ARM64 chip reads instructions 4 bytes at a time and gives those bytes no such meaning. Even on the same processor, Windows, macOS and Linux package programs in different file formats and offer different system calls, so a program is built for one processor and one operating system.What is the difference between machine code and bytecode?
.class files and Python .pyc files hold bytecode, which runs on any computer that has the virtual machine, and a JIT compiler can turn the busiest parts into machine code while the program runs.Can humans write machine code?
Yes, and the first programmers did, entering numbers by hand with switches or punched cards. It is slow and easy to get wrong, because every address has to be worked out by hand, which is why assembly languages appeared as early as the late 1940s. Today people read machine code in a debugger far more often than they write it.