ebreak

ebreak

RISC-V Assembly Reference

lyszt.net covers ebreak and other RISC-V instructions in more detail.

Description

ebreak stops the program. The name is short for environment break. It marks a point where a debugger takes control, and this simulator halts execution at that line. The form takes no operands.

ebreak

The processor stops there and the lines after it do not run. Registers and memory keep their values, so the state at the breakpoint can be inspected afterward. ecall with service 10 ends a program normally, and ebreak stops it at a chosen spot.

The RISC-V manual describes ebreak as returning control to a debugging environment, and it defines it together with ecall, which asks the environment for a service. Both cause a precise requested trap, a deliberate transfer of control to the environment.

The example sets t0 to 1 and runs ebreak. The li after it never runs, so t0 stays 1.

Example

li t0, 1
ebreak   # the program stops here
li t0, 2   # never reached