RISC-V Assembly Language Learning Roadmap (6 Weeks)
📘 Week 1 – Foundations of Computer & Number Systems
Goal: Build the math and logic base for assembly programming.
Topics:
• Binary, decimal, and hexadecimal conversions
• Bitwise operations (AND, OR, XOR, NOT, shifts)
• Signed vs. unsigned integers
• Two’s complement representation
Exercises:
• Convert numbers between bases by hand
• Write out binary addition/subtraction examples
• Perform bitwise operations manually
Resources:
• Computerphile – Binary Basics (YouTube)
• Nand2Tetris Part I (first few chapters on machine data)
📗 Week 2 – RISC-V Architecture & Instruction Basics
Goal: Understand the RISC-V CPU structure and how basic instructions work.
Topics:
• RISC vs. CISC architecture
• RISC-V register file (x0–x31)
• R-type, I-type, S-type, B-type, U-type, J-type instruction formats
• Arithmetic and logical operations (add, sub, addi, and, or, etc.)
Exercises:
• Identify instruction formats from examples
• Write small programs: add two numbers, subtract and store results in a register
Tools:
• Install RARS or use Venus (online): [Link]
Resources:
• RISC-V Green Card (instruction summary)
• RARS Documentation (GitHub)
📙 Week 3 – Memory, Load/Store, and Branching
Goal: Work with memory and control flow.
Topics:
• Memory addressing and load/store (lw, sw, la, li)
• Branch and jump instructions (beq, bne, jal, jalr)
• Loops and conditional logic
• Understanding the Program Counter (PC)
Exercises:
• Compare two numbers
• Count from 1–10 using a loop
• Compute the sum of numbers in an array
• Challenge: Implement a 'find max in an array' routine.
📕 Week 4 – Procedures, Stack, and Functions
Goal: Learn structured program design in assembly.
Topics:
• Function calls with jal and jr
• Using the stack (sp, ra)
• Register conventions (a0–a7, t0–t6, s0–s11)
• Parameter passing and returning values
Exercises:
• Factorial (using recursion)
• Fibonacci sequence
• Swapping two numbers using the stack
Resource:
• UC Berkeley CS61C RISC-V calling convention guide
📒 Week 5 – Input/Output & System Calls
Goal: Learn to communicate with the system.
Topics:
• RARS system calls (print integer, read integer, print string)
• Using ecall instruction
• Simple text-based interaction
Exercises:
• Ask the user for a number and print its square
• Input two numbers and output their sum
• Challenge: Create a small menu program (add, subtract, multiply, divide).
📓 Week 6 – Advanced Topics & Mini Projects
Goal: Build real mini-projects and explore advanced concepts.
Topics:
• Instruction encoding and pipeline basics
• Arrays, strings, and loops in memory
• Interrupts (intro)
• Assembling with riscv64-unknown-elf-gcc (optional)
Mini Projects:
1. Bubble Sort in RISC-V Assembly
2. Reverse a string
3. Simple calculator
Stretch Goals:
• Learn about RISC-V Privileged ISA
• Explore embedded RISC-V boards (SiFive, ESP32-C3)
🧰 Recommended Tools
• Online simulator: [Link]
• Offline IDE: RARS (GitHub)
• Compiler/debugger: RISC-V GNU Toolchain
• Visualization: RARS step-through execution mode
📚 Optional Books & References
• The RISC-V Reader – Patterson & Waterman
• Computer Organization and Design RISC-V Edition – Patterson & Hennessy
• UC Berkeley CS61C Lecture Notes
Name Description
Align next data item on specified byte boundary (0=byte, 1=half, 2=word,
.align
3=double)
.ascii Store the string in the Data segment but do not add null terminator
.asciz Store the string in the Data segment and add null terminator
.byte Store the listed value(s) as 8 bit bytes
.data Subsequent items stored in Data segment at next available address
Name Description
.double Store the listed value(s) as double precision floating point
.end_macr
End macro definition. See .macro
o
Substitute second operand for first. First operand is symbol, second operand
.eqv
is expression (like #define)
.extern Declare the listed label and byte length to be a global data field
.float Store the listed value(s) as single precision floating point
.globl Declare the listed label(s) as global to enable referencing from other files
.half Store the listed value(s) as 16 bit halfwords on halfword boundary
.include Insert the contents of the specified file. Put filename in quotes.
.macro Begin macro definition. See .end_macro
Allows specifying sections without .text or .data directives. Included for gcc
.section
comparability
.space Reserve the next specified number of bytes in Data segment
.string Alias for .asciz
Subsequent items (instructions) stored in Text segment at next available
.text
address
.word Store the listed value(s) as 32 bit words on word boundary