Skip to content
systemcoding.dev
Fundamentals

What an Instruction Set Architecture (ISA) Is

An ISA is the contract between software and a processor: instructions, registers, encodings. See one add function as x86-64, AArch64 and RISC-V code and bytes.

6 min read
Summarize in AI
Flat illustration of an assembly listing with addresses and mnemonics, with the GNU, AMD and Arm logos.

A program compiled for your laptop will not run on a phone, even though both are made of transistors and both run the same operating system family. The reason is that the two processors speak different languages: the bit patterns that mean "add these two registers" on one mean something else, or nothing, on the other. The specification of that language, together with the machine state it operates on, is the instruction set architecture, the ISA.

This post defines an ISA, separates it from the chip that implements it, and shows the same C function compiled for x86-64, AArch64 and RISC-V so the differences are visible byte by byte. The compiler is GCC 14 at -O2, and the machine code was assembled by hand from the architecture manuals, so you can follow every bit.

What an ISA specifies

An ISA is a contract. Software promises to use only what the contract describes, and hardware promises to behave as the contract says. The contract covers:

  • Instructions: which operations exist (add, load, branch) and what each does to the machine state.

  • Registers: how many, how wide, and which have special roles, such as the program counter and stack pointer.

  • Data types and widths: 8, 16, 32 and 64-bit integers, floating point formats, vectors.

  • Memory model: how addresses work, byte order (endianness), alignment rules and, for multi-core systems, what ordering other cores may observe.

  • Addressing modes: how an instruction names its operands: a register, an immediate constant, a memory address built from a base and an offset.

  • Encoding: the exact bits that represent each instruction.

  • Privilege and exceptions: modes, interrupts, and how the processor reports faults.

Anything the ISA leaves unspecified is up to the implementer, which is the point of the next section.

ISA versus microarchitecture

The ISA is the interface. The microarchitecture is how a specific chip implements it: pipeline depth, cache sizes, number of execution units, branch predictor. Many chips with very different internals share one ISA. An old x86-64 core and a current one run the same binary and produce the same results, though at very different speeds. Arm sells an ISA and designs cores for it, and other companies design their own cores for the same ISA.

This separation is why binary compatibility lasts decades. A processor can be rebuilt from scratch, as long as the contract is honored. It is also why "64-bit" and "x86" say little about performance: they describe the contract, not the machine.

The same function in three ISAs

Take the smallest useful function:

add.cc
int add(int a, int b) {
    return a + b;
}

Compile it for each target with -O2 -S and the output is the assembly the processor's ISA defines. The three listings below are what GCC 14 produces for each, with directives removed.

Shell
gcc -O2 -S add.c -o add-x86.s
aarch64-linux-gnu-gcc -O2 -S add.c -o add-arm.s
riscv64-linux-gnu-gcc -O2 -S add.c -o add-rv.s
Text
x86-64:
    leal    (%rdi,%rsi), %eax
    ret

AArch64:
    add     w0, w0, w1
    ret

RISC-V (RV64):
    addw    a0, a0, a1
    ret

All three read two arguments from registers and return the sum in a register, and the calling convention names those registers differently: rdi and rsi in, eax out for the System V x86-64 ABI, w0 and w1 in and w0 out for AArch64, a0 and a1 in and a0 out for RISC-V. That register assignment is part of the ABI, a layer above the ISA, but each ISA's register set makes it possible.

Notice the x86-64 version does not use add. GCC chose lea, load effective address, because it computes rdi + rsi into a different destination register in one instruction without overwriting either input. That is the kind of trick an ISA with flexible addressing modes allows, and RISC-V and AArch64 do not need it because their add already has a separate destination.

The same function in machine code

The assembly is a human-readable form of the encoding. This is what the processor actually reads, in the byte order stored in memory:

ISAInstructionBytes in memorySize
x86-64lea eax, [rdi+rsi]8d 04 373 bytes
x86-64retc31 byte
AArch64add w0, w0, w100 00 01 0b4 bytes
AArch64retc0 03 5f d64 bytes
RISC-Vaddw a0, a0, a13b 05 b5 004 bytes
RISC-Vret67 80 00 004 bytes

You can verify these. The AArch64 add w0, w0, w1 is the 32-bit word 0x0B010000: the top bits 0 0 0 01011 select an add of shifted registers, then the register Rm is 1, the base register Rn is 0 and the destination Rd is 0. Written in little-endian order, the bytes are 00 00 01 0b. The RISC-V addw a0, a0, a1 encodes as the word 0x00B5053B: opcode 0111011 in the low bits, destination 10 (a0), function bits 0, source 10 (a0), source 11 (a1), and a zero upper function field, stored as 3b 05 b5 00. The x86-64 lea is 8d for the opcode, then a ModRM byte 04 meaning a scaled-index byte follows with destination eax, and that byte 37 meaning base rdi plus index rsi.

Two differences stand out. AArch64 and RISC-V instructions are all 4 bytes in these examples, because their base ISAs use fixed 32-bit encodings, which makes decoding simple. RISC-V also defines an optional compressed extension with 16-bit instructions. x86-64 instructions range from 1 to 15 bytes, which packs code more densely but makes decoding harder, and modern x86 cores decode into simpler internal operations first.

Families of design

Textbooks split ISAs into two broad styles, and the split is useful as a first guide.

PropertyCISC (x86-64 is the example)RISC (AArch64, RISC-V)
Instruction lengthVariable, 1 to 15 bytesFixed 4 bytes in the base ISA
Memory operandsArithmetic can read or write memoryOnly load and store touch memory
RegistersFewer visible, with special rolesMany general-purpose, uniform
DecodeComplexSimple

The line has blurred. x86-64 cores translate to RISC-like micro-operations internally, and modern RISC ISAs have grown many instructions. Treat the table as a description of origins, not a rule.

Why a programmer should care

The ISA decides what you see when you read disassembly, what the compiler can do, and what you must write by hand in a boot loader or a context switch. It also decides portability: source code in C moves between ISAs by recompiling, while a binary does not. Cross-compilers exist because the compiler runs on one ISA and emits another, and emulators such as QEMU exist because one machine can pretend to implement another's contract in software.

A few terms you will meet follow from this. An ABI sits above the ISA and fixes calling conventions and data layout for one operating system. A microarchitecture is a chip design. An extension adds instructions to a base ISA, like AVX for x86-64 or the vector extension for RISC-V, and software checks for it at run time.

What the ISA does not tell you

An ISA does not say how fast an instruction is, how big the caches are, or how many cores exist. Two chips with the same ISA can differ by an order of magnitude in speed. It also does not describe the rest of the computer: the interrupt controller, the memory map and the boot process belong to the platform, not the ISA, which is why two ARM boards with the same core need different board support code.

Also inHardware
Share

Keep reading

Flat illustration of user space above the system call boundary, the kernel and the hardware, with the C, FreeBSD and Linux logos.
Systems Programming

How argc and argv Reach main in a C Program

The kernel copies argc and argv onto the new process's stack on execve, then startup code hands them to main. See the layout and measure it with a program.

6 min read

Get new posts by email

We send one email when a new post is published. No spam.

Unsubscribe in one click. No spam, ever.