C Mastery / Architectures: x86, x86-64, ARM, ARM64, RISC-V
Part 7 — CPU Architecture and Assembly

Architectures: x86, x86-64, ARM, ARM64, RISC-V

This chapter surveys the major CPU architectures you will encounter in C systems work: x86/x86-64, ARM/ARM64, and RISC-V.

Why This Matters

C is portable across architectures, but systems and embedded work often targets a specific one. Knowing the families — their register models, calling conventions, and instruction-set character — helps you read assembly and understand performance.

Prerequisites

Core Concept

ArchitectureTypeNotes
x86CISC, 32-bitlegacy desktop/server
x86-64CISC, 64-bitdominant desktop/server
ARMRISC, 32-bitembedded, mobile
ARM64 (AArch64)RISC, 64-bitmobile, server, Apple Silicon
RISC-VRISC, 32/64-bitopen ISA, growing

Key Characteristics

x86 / x86-64

+ 16 in total).

ARM / ARM64

RISC-V

Examples

Same C, different assembly

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

x86-64:

add:
    lea eax, [rdi + rsi]
    ret

ARM64:

add:
    add w0, w0, w1
    ret

RISC-V (RV64):

add:
    addw a0, a0, a1
    ret

How It Works

Each architecture defines registers, instructions, and an ABI. The compiler's back end emits target-specific code; the same C source compiles to different assembly per target.

Variations

32-bit vs. 64-bit

The same family has 32-bit and 64-bit variants with different register widths and ABIs (e.g., ARM vs. AArch64).

Extensions

SIMD extensions differ: SSE/AVX on x86, NEON/SVE on ARM, vector extensions on RISC-V.

Common Mistakes

Undefined Behavior

constrained by the target.

Portability

detection (c.pp.conditional).

Under the Hood

The compiler targets an architecture via its back end. Cross compilers produce code for a target different from the host (c.build.9).

Practical Usage

Exercises

1. Compile the same function for x86-64 and ARM64 (cross compiler if available) and compare. 2. Look up the register sets of ARM64 and RISC-V. 3. Explain the difference between ARM and ARM64 (AArch64).

Deep Challenge

Explain how a calling convention differs between x86-64 System V and ARM64 AAPCS, and write a small C function, then compare its generated prologue/ epilogue on both.

References

Verification

verified.`

Progress

Concept checkboxes

Mastery levels

ConceptCurrent level (0–8)Target level
c.cpu.x8605
c.cpu.arm05
c.cpu.riscv05