Skip to content
Tutorials Center
My learning

Topics

Lesson 18 of 67 ยท Instruction Set Architecture

Instruction Set Architecture

Learn what an instruction set architecture defines, from registers and memory model to instruction types, and compare RISC and CISC, x86, ARM and RISC-V.

When you write a program in Python, C or Java, you never mention a transistor. Between your code and the hardware sits one precise boundary: the instruction set architecture, or ISA. The ISA is the contract that says what a processor can do, how programs name the data they work on, and what each instruction means. Compilers produce code for an ISA, and processors are built to run it.

This lesson explains what the contract contains, why separating it from the hardware design matters, and how the main families (x86, ARM, RISC-V) differ. It also introduces the small teaching ISA used in the next few lessons, so you can see an ISA as something concrete rather than a catalogue of terms.

What an ISA defines

An ISA is the part of a processor that software can see. It specifies:

  • Instructions: the operations (add, load, branch, ...) and what each does to the machine state.
  • Registers: how many, how wide, and which ones are special (a program counter, a stack pointer, a flags register).
  • Data types: sizes of integers and, if supported, floating-point and vector values.
  • Memory model: how memory is addressed (bytes or words), how big an address is, whether values must be aligned, and the byte order (endianness) of multi-byte numbers.
  • Instruction encoding: the bit patterns that represent instructions (covered in Instruction Formats and Encoding).
  • Addressing modes: the ways an instruction can specify an operand (see Addressing Modes).
  • Exceptions, interrupts and privilege levels: how the machine reacts to errors and devices, and how the operating system is protected from user programs.

What the ISA does not define is how the instructions are carried out. That belongs to the microarchitecture, also called the organization. This is the same split you met in What Is Computer Organization and Architecture?: architecture is what the programmer sees, organization is how it is built.

flowchart TB
  APP["Your program"] --> COMP["Compiler / assembler"]
  COMP --> ISA["ISA: the contract<br/>instructions, registers, memory model"]
  ISA --> M1["Microarchitecture A<br/>small, low power"]
  ISA --> M2["Microarchitecture B<br/>wide, out-of-order, fast"]

One ISA, many implementations: the same machine code runs on both.

This separation is why a program compiled in 2010 for x86 still runs on a processor released last year. The internals have changed completely (deeper pipelines, caches, speculation), but the contract is the same. It is also why the ISA is so hard to change once software depends on it.

The architectural state

At any moment the visible state of the machine is small: the program counter, the registers and memory. Executing one instruction changes that state, and every ISA is defined as a rule for how. Results must look as if instructions ran one at a time, in order, even when the hardware overlaps or reorders them internally.

Registers are the fastest storage the programmer can name. Typical sets:

Kind Examples Purpose
General-purpose 16 on x86-64, 31 on 64-bit ARM, 31 on RISC-V Integers and addresses
Program counter rip, pc Address of the next instruction
Stack pointer rsp, sp Top of the call stack
Status flags x86 rflags, ARM NZCV Results of comparisons; RISC-V has none
Floating-point and vector xmm, v0 to v31 Floating-point and SIMD data

Some ISAs hard-wire register 0 to the value zero, which gives free "move" and "load constant" idioms. Our teaching ISA does this.

Types of instructions

Despite their differences, nearly all ISAs offer the same four families:

  1. Data processing: arithmetic, logic, shifts, comparisons.
  2. Data transfer: loads and stores between registers and memory, plus register-to-register moves.
  3. Control flow: jumps, conditional branches, calls and returns.
  4. System: halting, system calls, interrupt handling, cache and privilege control.

How many operands live in memory?

ISAs are also classified by where an instruction's operands come from. The classic styles are:

  • Stack machine: operands are implicit on top of a stack. ADD pops two values and pushes the sum. Compact code, but every value is touched through the stack. The Java virtual machine and WebAssembly use this style.
  • Accumulator machine: one implicit register, the accumulator, is both a source and the destination. The tiny machine in The Von Neumann Model and the Fetch-Decode-Execute Cycle works like this.
  • Register machine, register-memory: instructions may use a memory operand directly, as x86 does.
  • Register machine, load-store: arithmetic works only on registers, and separate load and store instructions move data. ARM and RISC-V work this way.

The next TryIt computes e = (a + b) * (a - b) on three tiny machines of these styles and counts instructions and memory traffic. Note how the stack and accumulator versions must fetch a and b more than once, while the load-store version reads each variable once and keeps it in a register.

Python The same expression on three machine styles

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

All three get 40, but the load-store machine needs only two memory reads, while the accumulator machine needs five reads and two writes because it has nowhere to keep temporary values except memory. That is the main reason general-purpose registers won.

RISC versus CISC

Two design philosophies shaped the field.

CISC (complex instruction set computer) packs a lot of work into one instruction: memory operands, string operations, many addressing modes, instructions of different lengths. It came from an era when memory was expensive and programmers wrote assembly, so dense code and rich instructions were valuable.

RISC (reduced instruction set computer) keeps instructions simple, uniform and fast: fixed length, load-store architecture, many registers, few addressing modes. Simple, regular instructions are easy to decode and to pipeline, which you will explore in Instruction Pipelining.

CISC (classic) RISC (classic)
Instruction length Variable Fixed
Memory operands Allowed in many instructions Only in load and store
Addressing modes Many Few
Registers Fewer Many
Code size Smaller Larger
Decoding Complicated Simple
Examples x86, VAX, z/Architecture MIPS, ARM, RISC-V, PowerPC

Today the line is blurry. Modern x86 processors translate their complex instructions into simple internal micro-operations and then run them on a RISC-like core. ARM has gained many instructions over the years. The practical difference lies mostly in the encoding and in the cost of decoding, not in raw speed.

The big three

x86 and x86-64. Descended from Intel's 8086 (1978) and extended again and again, with full backward compatibility. Variable-length instructions (1 to 15 bytes), memory operands, a flags register, and a huge family of extensions (SSE, AVX). It dominates desktops, laptops and servers. Because of its age, the decoder is a complicated piece of silicon.

ARM. A licensed RISC family. The 64-bit version, AArch64, has 31 general registers, fixed 32-bit instructions and condition flags. ARM cores power nearly every phone and are common in laptops (Apple silicon) and servers. ARM Ltd. sells designs and licenses the ISA, and companies build their own chips.

RISC-V. An open ISA created at the University of California, Berkeley, which anyone can implement without paying a licence. It has a tiny mandatory base (RV32I or RV64I) with optional extensions (multiply, atomics, floating-point, vectors, compressed 16-bit instructions). It uses a load-store design, 32 registers with x0 fixed at zero, and no flags register: branches compare registers directly. It is popular in education, embedded systems and research.

The same C function, int add(int a, int b) { return a + b; }, compiles to something like this on each (shown read-only, as produced by a typical optimizing compiler):

TEXT
x86-64:    lea  eax, [rdi + rsi]
           ret

AArch64:   add  w0, w0, w1
           ret

RISC-V:    addw a0, a0, a1
           ret

Each ISA passes the arguments in different registers (this is the platform's calling convention, part of the ABI, the application binary interface), and each uses a different instruction name, but the idea is identical.

A teaching ISA: TC16

Real ISAs are large, so for the next lessons we will use a small invented one called TC16. It borrows the cleanest ideas from MIPS and RISC-V and is small enough to hold in your head, encode by hand and simulate completely.

  • 16-bit words and instructions, a word-addressed memory of 4,096 words
  • 8 registers r0 to r7, where r0 always reads as zero
  • A load-store design with 15 instructions: arithmetic and logic, lw/sw, branches, a jump and halt

The TryIt writes this contract down as data and derives facts from it, then looks at one thing the ISA deliberately leaves unspecified for a given machine, the byte order.

Python An ISA written down as data

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Register-field width follows directly from the register count: eight registers need 3 bits to name, so an instruction that names three registers spends 9 of its 16 bits just on registers. Design trade-offs like that one are what Instruction Formats and Encoding is about.

Endianness is a good example of a choice every ISA must make. x86 and most ARM systems store the least significant byte first (little endian), while network protocols use big endian. Both orders are correct as long as software and hardware agree. See Characters, ASCII and Unicode for how it shows up in text encodings.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. What does an ISA specify?

    The ISA is the software-visible contract. Transistors, clock speed and caches belong to the microarchitecture and can change without breaking programs.
  2. 2. Why can old x86 programs run on a brand-new x86 processor?

    Compatibility lives at the ISA level. Different microarchitectures can implement the same contract.
  3. 3. Which is a typical RISC feature?

    RISC designs use fixed-length instructions, touch memory only through loads and stores, and provide many registers.
  4. 4. In a load-store architecture, how does the program add two numbers that are in memory?

    Arithmetic works only on registers, so values are loaded first and results stored afterwards.
  5. 5. Which statement about RISC-V is correct?

    RISC-V is an open standard. Implementers choose the base (RV32I, RV64I) and any extensions they need.

Summary

  • The ISA is the contract between software and hardware: instructions, registers, data types, memory model, encoding, addressing modes and exceptions.
  • Microarchitecture (organization) is how an ISA is implemented. Many designs can implement one ISA.
  • Architectural state is the program counter, registers and memory; instructions must appear to run in order.
  • Operand styles range from stack and accumulator machines to register machines, with load-store designs dominating modern ISAs.
  • RISC favors simple, fixed-length, load-store instructions; CISC favors dense, variable-length instructions with memory operands. Modern chips blend the two.
  • x86 is the long-lived CISC giant, ARM the licensed RISC family in phones and laptops, and RISC-V the open RISC ISA.
  • TC16, our 16-bit teaching ISA, will be encoded, assembled and simulated in the next lessons.

Continue with Instruction Formats and Encoding.