title date categories tags
RISC-V Code Model
2024-06-13 17:30:00 +0800
RISC-V
code model
risc-v

RISC-V only has three addressing modes:

medlow

The program and its statically defined symbols must lie within a single 2 GiB address range and must lie between absolute addresses −2 GiB and +2 GiB. Programs can be statically or dynamically linked.

lui a0, xxxx
addi a0, a0, xxxx

medany

The program and its statically defined symbols must be within any single 2 GiB address range. Programs can be statically or dynamically linked.

Reference

https://www.sifive.com/blog/all-aboard-part-4-risc-v-code-models

https://gcc.gnu.org/onlinedocs/gcc/RISC-V-Options.html