ISARef Multi-ISA & Silicon Reference
45,419 ISA items · 105,907 timings · 1,823 microarchs · 16,083 chips · 105 sources
Arch:
Tier:

mepc

T1 riscv register register
Machine Exception Program Counter
SourceRISC-V Official Unified Database (riscv-unified-db) (riscv_unified_db)
Reliability TierT1 — Official Specification
ISA / Silicon ScopeRISC-V Privileged (Sm)
RV32 / RV64 (Ratified & Standard Extensions)
License & VersionApache-2.0 / CC-BY-4.0
main
Upstreamhttps://github.com/riscv/riscv-unified-db
PrivilegeM
ExtensionsSm

Summary

Written with the PC of an instruction on an exception or interrupt taken in M-mode.

Syntax / Encoding

CSR 0x341 (M-mode, RW)

Bitfields (1)

BitsFieldDescription
63:0PCWhen a trap is taken into M-mode, mepc.PC is written with the virtual address of the instruction that was interrupted or that encountered the exception. Otherwise, mepc.PC is never written by the implementation, though it may be explicitly written by software. On an exception return from M-mode (from the MRET instruct