# LinuxCNC M70 Save Modal State

Instructions · `M70` · verification: source checked

M70 explicitly saves the current modal state at the current call level in LinuxCNC. The saved state can later be restored exactly by executing M72. A typical use is to protect a program against inadvertent modal changes inside subroutines.

## Specification

| Property | Value |
|---|---|
| Language | gcode |
| Code | M70 |
| Group | modal state |
| Syntax | M70 |
| Dialect | LinuxCNC |

## Study notes

- M70 saves modal state at the current call level; M72 restores that saved state.
- A pair of M70 and M72 instructions is typically used to protect a program against inadvertent modal changes within subroutines.
- At the main program level there is a single storage location for state; if several M70 instructions are executed in turn, only the most recently saved state is restored when M72 is executed.
- Within a G-code subroutine, state saved with M70 behaves like a local named parameter: it can be used with M72 only within that subroutine invocation and goes away when the subroutine exits.
- A recursive invocation of a subroutine introduces a new call level.
- M70 saves G20/G21 units, selected plane, cutter compensation status, distance mode, feed mode, current coordinate system, tool length compensation status, retract mode, spindle mode, arc distance mode, lathe radius/diameter mode, path control mode, current F and S values, spindle status, mist and flood status, speed and feed override settings, adaptive feed setting, and feed hold setting.
- The motion mode, such as G1, is not restored.
- Modal state saved with M70 at the current call level can be invalidated with M71; a subsequent M72 at the same call level will fail.
- M73 saves modal state within a subroutine and restores state on endsub or return; aborting a running program in a subroutine with an M73 operation will not restore state.

## Sources

1. [M-Codes](https://linuxcnc.org/docs/html/gcode/m-code.html#mcode:m70) (accessed 2026-10-26)

---

Source page: https://machineschema.com/instruction/mcode-m70  
JSON: https://machineschema.com/instruction/mcode-m70.json  
License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Cite Machine Schema and the original sources.
