"It has come to the Triarii"
The RISC-V instruction set is modular. It has a small mandatory base integer specification and optional standard extensions. There is no single monolithic "complete" list for all use cases. Chips mix a base (like RV32I or RV64I) with extensions for multiplication, atomics, and floating-point.
The core 32-bit or 64-bit base integer instruction set (RV32I/RV64I) containing basic math, loads, stores, and control flow.
People new to programming should be exposed to assembly language programming to get a feel of how computers work.
I created/collected this hodgepodge of material to teach myself something about RISC-V assembly language programming. It could be used as the start of an assembly language programming course after it is cleaned up and reorganized.
Note: Over the years I have programmed a little in 6 or 7 different assembly languages.
RISC-V (Wikipedia)
RISC-V assembly language (Wikipedia)
RISC-V instruction listings (Wikipedia)
You Can Learn RISC-V Assembly in 10 Minutes | Getting Started RISC-V Assembly on Linux Tutorial (YouTube)
RISC-V Assembly Code #1: Course Intro, Registers
(YouTube)
RISC-V Assembly Code #2: ALU, Load, Store Instructions
(YouTube)
RISC-V Assembly Code #3: Branch, Jump, Call, Return, etc
(YouTube)
RISC-V Assembly Code #4: Asm Directives, Pseudo Instructions
(YouTube)
RISC-V Assembly Code #5: RV32 v RV64
(YouTube)
RISC-V Assembly Code #6: Multiply, Divide Instructions
(YouTube)
RISC-V Assembly Code #7: Example Program
(YouTube)
RISC-V Assembly Code #8: Floating Point-IEEE 754
(YouTube)
RISC-V Assembly Code #9: Floating Point Instructions (pt. 1)
(YouTube)
RISC-V Assembly Code #10: Floating Point Instructions (pt. 2)
(YouTube))
Beginners RISC-V Assembly (YouTube)
This example uses the standard C library write command. It is
more complicated than the RARS simulator. I suggest you come
back to this later when you know more RISC-V assembly Language.
RISC-V Assembly Hello World (Part 1)
(YouTube)
RISC-V Assembly Hello World (Part 2)
(YouTube)
QEMU - A generic open source machine emulator and virtualizer (I use RARS. See below.)
RISC-V Assembly Language Reference Card
RISC-V Syscalls
(RISC-V assembly system calls are executed
using the ecall instruction (system call). By standard convention,
the system call number must be loaded into register a7, and any
required arguments are passed through registers a0 to a6.)
RISC-V Assembly Programmer’s Manual
RISC-V Assembly Programming
(The website contains a set of resources to support learning/teaching
assembly programming using the RISC-V ISA.)
(Instruction Set Architecture (ISA))
This is the assembler/simulator I am using to learn RISC-V assembly language programming. It is written in Java and should run everywhere Java runs. (Windows, MAC, Linux, ...)
1. To execute a Java JAR files on Windows 10, install Java Runtime Environment (JRE) or Java Development Kit (JDK) (requires Java 8+). You can download the latest official version from java.com.
2. Create a <work folder> on the desktop or wherever you want.
3. Download the latest RARS jar file (rars1_6.jar?) to the <work folder>. (I downloaded it from HERE.)
4. Execute RARS
5. RARS .include
The .include directive inserts the contents of another assembly source file directly into your current file during the preprocessing stage.
6. RARS allow source code (functions, libraries, macros, ...) to be in separate files. This means a program can be made up of multiple files.
7. You can change RARS fonts via menu: Settings > Highlighting.
8. RARS Links
Lab1 Intro to RARS
(RARS) RISC-V Assembler and Runtime System
(RARS system calls)
RARS Wiki
Question: What is the difference between syscall 10 and syscall 93?
| .s (or .S) | .asm | |
|---|---|---|
| Primary Toolchain | GNU Assembler (GAS) / GCC / Clang | Keil, MARS, Venus, or Windows-based IDEs |
| C Preprocessor | Supported automatically if using uppercase .S | Generally not supported |
| Compiler Output | Default extension when compiling C to assembly (gcc -S) | Rarely generated automatically by modern compilers |
| Portability | Standard for Linux, embedded RTOS, and open-source RISC-V | Common in academic simulators and legacy microcontrollers |
32-bit architecture assembly language.
Image From: commons.wikimedia.org
Note:
| Project #1 | Project #2 | Project #3 | Project #4 |
| Project #5 | Project #6 | Project #7 | Project #8 |
| Project #9 | Project #10 | Project #11 | Project #12 |
| Project #13 | Project #14 |
RISC-V ALE Exercise Book
RISC-V Practice Problems
RISC-V-Assembly-Introductory-Exercises
| ABI | Application Binary Interface
RISC-V Defines 1. register aliases 2. calling conventions 3. caller-saved and callee-saved registers 4. stack management 5. data types and sizes 6. system calls 7. is the standard low-level contract that allows independently compiled code, libraries, and the operating system to work together. |
| ALU | arithmetic logic unit | CPU | central processing unit
(it is the "brain" of a computer)
1. fetches instructions from memory 2. decodes commands to determine what action to take 3. runs programs |
| ISA | instruction set architecture
1. an abstract model that defines the programmable interface of the CPU of a computer 2. defines how software interacts with hardware 3. defines what the physical processor instructions mean. |
Image From: commons.wikimedia.org
Bonus Question: Who was William 'Wild Bill' Gelbke?