Loading an Address into a CSR

Tonight’s @risc_v Tip:

You can use two convenient pseudo-instructions to load the address of a symbol into a CSR.

la t1, main => auipc t1, main[31:12]; addi t1, t1, main[11:0]

csrw mepc, t1 => csrrw x0, mepc, t1

21-11-02

Original Tweet