Instruction Set Architecture
The contract between hardware and software — instruction types, formats, addressing modes, registers, calling conventions, and how x86, ARM and RISC-V differ.
The instruction set architecture (ISA) is the interface between software and hardware: the instructions, registers, memory model and encodings a CPU promises to support. Compilers target the ISA; chip designers are free to implement it however they like. That's why the same binary runs on a cheap laptop chip and a server CPU.
What an ISA defines
- Instructions and what each does.
- Registers: how many, how wide, special roles (stack pointer, zero register…).
- Data types: integer widths, floating point, vectors.
- Addressing modes: how instructions name memory locations.
- Encoding: how instructions become bits.
- Memory model: endianness, alignment, and ordering rules between cores.
- Privilege levels, interrupts and exceptions.
Instruction categories
| Category | Examples (RISC-V) | Does |
|---|---|---|
| Arithmetic / logic | add, sub, and, or, sll | Compute on registers |
| Immediate | addi x5, x5, 1 | Use a constant in the instruction |
| Data transfer | lw (load word), sw (store word) | Move between registers and memory |
| Control flow | beq, bne, jal, jalr | Branch, jump, call, return |
| System | ecall, csrrw | System calls, control registers |
Instruction formats (RISC-V)
Fixed 32-bit instructions with fields in the same positions make decoding fast and simple.
| Format | Used for | Fields |
|---|---|---|
| R | register–register ops | rd, rs1, rs2 |
| I | immediates, loads | rd, rs1, 12-bit immediate |
| S | stores | rs1, rs2, 12-bit offset |
| B | branches | rs1, rs2, 13-bit offset |
| U / J | large constants, jumps | rd, 20-bit immediate |
Addressing modes
| Mode | Meaning | Example |
|---|---|---|
| Immediate | The operand is in the instruction | addi x1, x0, 42 |
| Register | The operand is in a register | add x1, x2, x3 |
| Base + offset | Memory at register + constant | lw x1, 8(x2) → field at offset 8 of a struct |
| PC-relative | Relative to the current instruction | Branches, position-independent code |
| Indexed / scaled (x86) | base + index × scale + disp | mov eax, [rbx + rcx*4 + 16] → arr[i] |
Comparing the big three
| x86-64 | ARM64 (AArch64) | RISC-V | |
|---|---|---|---|
| Style | CISC | RISC | RISC |
| Instruction length | 1–15 bytes | 4 bytes | 4 bytes (2 with the compressed extension) |
| General registers | 16 | 31 + zero register | 31 + x0 hardwired to 0 |
| Memory operands in ALU ops | Yes | No (load/store) | No (load/store) |
| Licensing | Intel/AMD only | Licensed by Arm | Open, royalty-free |
| Where | PCs, servers | Phones, Apple M-series, cloud | Embedded, growing everywhere |
Calling conventions
An ABI (application binary interface) extends the ISA with rules so separately compiled code can call each other: which registers hold arguments and return values, who saves which registers, and how the stack is laid out.
| x86-64 System V (Linux/macOS) | RISC-V | |
|---|---|---|
| Integer arguments | rdi, rsi, rdx, rcx, r8, r9 | a0–a7 |
| Return value | rax | a0 (a1) |
| Callee-saved | rbx, rbp, r12–r15 | s0–s11 |
| Return address | Pushed on the stack by call | Register ra |
Extensions
ISAs grow through extensions: SIMD (x86 SSE/AVX/AVX-512, ARM NEON/SVE, RISC-V V) processes 4–64 values per instruction; there are also crypto instructions (AES-NI), atomics, and matrix extensions for ML (Intel AMX, ARM SME). A compiler flag like -march=native lets it use whatever your CPU supports.
- The ISA is the hardware/software contract; microarchitecture is the hidden implementation.
- RISC: fixed-length instructions, load/store; CISC: variable-length instructions, memory operands.
- Addressing modes map directly to code patterns (struct fields, arrays, PC-relative jumps).
- The ABI/calling convention defines argument registers and who saves what.
- RISC-V is open; ARM dominates mobile and is growing in servers; x86 dominates PCs.