DRET

RISC-V DRET Instruction Details

Instruction ManualI-type

Debug-mode return: PC<-dpc and resume with the dcsr-recorded prv/v state (and pelp where applicable). It is defined only in D-mode and not when executing from the Program Buffer.

Instruction Syntax

dret
Operand Breakdown
Destination rd: general-purpose register receiving the result.
Source rs1: register holding the first operand.
Immediate imm: 12-bit signed value, sign-extended before operation with rs1.
DebugSystem & Privileged

Instruction Behavior

DRET is used by the Debug Module to resume normal execution. Its recommended encoding is 0x7b200073; execution restores PC from dpc and resumes normally at the privilege indicated by dcsr.prv and dcsr.v, restoring ELP from pelp where applicable. DRET is defined only in D-mode and not when executing from the Program Buffer; this page does not present undefined contexts as xRET behavior, illegal instructions, or fixed platform behavior.

Quick Understanding & Search Notes

DRET is a system-level instruction defined by the debug specification. This page covers architectural semantics only, not platform firmware policy.

DRET's recommended encoding is 0x7b200073, and PC is restored from dpc.
Normal execution resumes from dcsr.prv and dcsr.v, with ELP restored from pelp where applicable; it is not the interrupt-enable restore sequence of mret or sret.
It is defined only in D-mode and not from the Program Buffer; do not infer an exception or platform policy for undefined contexts.

Common Usage Scenarios

Debugger return

Understand this scenario with real code like «dret».

Hardware breakpoint resume

Understand this scenario with real code like «dret».

Pre-Use Checklist

Syntax Check
  • Verify the immediate field is within the valid range.
  • Confirm source register rs1 points to the correct operand.
Semantic Check
  • Check if the immediate sign-extension matches expectations.
  • Ensure the result register rd has a clear purpose.

Pitfalls / Common Confusions

Only in Debug Mode
Not standard ISA

FAQ

Is it a normal user-mode instruction?

No. DRET is defined only in D-mode and not when executing from the Program Buffer; it is not a user-mode assembly instruction.

Which architectural state does DRET restore?

PC is restored from dpc; normal execution resumes according to dcsr.prv and dcsr.v, with ELP restored from pelp where applicable. The specification does not define it as the interrupt-enable restoration sequence of mret or sret.