RISC-V ECALL Instruction Details
Instruction ManualI-typeMake a service request to the execution environment; generates a precise environment-call trap
Instruction Syntax
Instruction Encoding
ECALL uses opcode 1110011 (0x73), funct3 000, funct12 000000000000. The rs1 field selects the source register, the 12-bit immediate provides the second operand, and rd selects the destination.
Instruction Behavior
ECALL (I-type encoding with all-zero immediate, rs1=x0, funct3=000, rd=x0, opcode=SYSTEM=1110011) generates a precise trap, transferring control to the execution environment. The EEI defines parameter passing (usually via registers). Used for system calls: user-mode programs request OS services via ECALL. Previously named SCALL (Supervisor Call), renamed to reflect broader usage beyond supervisor calls.
Common Usage Scenarios
Understand this scenario with real code like «ecall # request service from execution environment».
Understand this scenario with real code like «ecall # request service from execution environment».
Pre-Use Checklist
- Confirm the current instruction format is I-type.
- Confirm the operand order matches the example.
- Ensure the destination register usage is compatible with the calling convention.
- Confirm this is not the lower-level form of a pseudo-instruction expansion.