LinuxCNC M70 Save Modal State

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.

Source checked3/3 values · 2026-10-26

Specification

1 source
Languagegcode
CodeM70
Groupmodal state
SyntaxM70
DialectLinuxCNC

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.
↑↓ navigate↵ openesc close