{"id":"mcode-m72","model_id":"M72","name":"LinuxCNC M72","summary":"M72 is a LinuxCNC M-code that restores modal state previously saved with M70 at the current call level. It lets a subroutine change modes such as units, distance mode, feed and spindle settings and then hand the original state back to the calling program. If the length units are about to change, M72 restores the distance mode first so the feed value is interpreted in the correct unit setting.","study_notes":["M72 restores exactly the state captured by an M70 executed at the same call level; it is an error to run M72 with no previous M70 save at that level.","Saved state includes G20/G21, selected plane, cutter compensation status, distance mode (G90/G91), feed mode (G93/G94, G95), current coordinate system (G54-G59.3), tool length compensation status and retract mode (G98/G99).","Saved state also includes spindle mode (G96/G97), arc distance mode (G90.1/G91.1), lathe radius/diameter mode (G7/G8), path control mode (G61, G61.1, G64), current F and S values, spindle status (M3/M4/M5) with direction, and mist (M7) and flood (M8) status.","Saved state also includes speed override (M51) and feed override (M50) settings, adaptive feed (M52) and feed hold (M53) settings.","The motion mode (G1 etc.) is explicitly NOT restored by M72.","At the main program level there is a single storage location: if several M70 instructions run in turn, only the most recently saved state is restored by M72.","Within a G-code subroutine the M70/M72 state behaves like a local named parameter; it can only be referenced within that subroutine invocation and disappears when the subroutine exits.","A recursive subroutine invocation introduces a new call level with its own saved state.","An M70/M72 pair is typically used to protect a program against inadvertent modal changes inside subroutines.","M72 is the explicit counterpart to M70; M73 is the alternative that saves state in a subroutine and restores it automatically on return or endsub."],"safety_notes":[],"sources":[{"url":"https://linuxcnc.org/docs/html/gcode/m-code.html#mcode:m72","title":"M-Codes","accessed":"2026-10-26"}],"verification":{"status":"source_checked","checked_at":"2026-10-26","values":3,"method":"llm_source_check"},"updated_at":"2026-10-26","type":"instruction","spec":{"language":"gcode","code":"M72","syntax":"M72","parameters":[],"dialect":"LinuxCNC","related":["gcode-g20","gcode-g21"],"standards":[]},"url":"https://machineschema.com/instruction/mcode-m72","license":"https://creativecommons.org/licenses/by/4.0/"}