Master the fundamental concepts of instruction set architecture through this focused micro-challenge.
Writing one function in x86-64, ARM64, and RISC-V assembly exposes how ISA design shapes code size, register pressure, and encoding complexity.
asmLoading…
For example, adding two integers might take three instructions on x86 (move, add, return) but two on ARM and RISC-V because arguments already sit in w0/a0 and w1/a1.
For this exercise, you will implement add_numbers stubs for each architecture and compare instruction counts and byte sizes. This task asks you to connect encoding differences to Apple's Arm transition and LLVM's separate backend code generators.
Keep the relevant datasheet, ISA manual, or architecture textbook chapter open while you implement. When your output disagrees with the reference trace on the same program, the bug is usually a mis-decoded opcode, a stale register read, or a flag bit left unchanged after arithmetic.
For this exercise, you will use those habits while implementing the requirement in the starter code. Microarchitectural product names change across CPU generations, but the control ideas (fetch, bypass, cache lines, vector lanes) stay stable enough to debug from first principles.
Implement and compare same function across three architectures.
Requirements:
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
All starter code and reference implementations are available for your local setup.
View on Github