M-code reference

M99 M-Code: Subprogram Return / Loop

Subprogram Return / Loop — At the end of a subprogram it returns to the calling program. At the end of a main program it jumps back to the start — used for bar-feeder loops and warm-up…

By cnccode · Updated
PropertyValue
CodeM99
FunctionSubprogram Return / Loop
Used onMills and lathes

What does M99 do?

At the end of a subprogram it returns to the calling program. At the end of a main program it jumps back to the start — used for bar-feeder loops and warm-up programs.

M99 example

Example
O1001
G91 G01 Z-2.0 F150.
G90 X50.0
M99

Tips

  • M99 Pn returns to block Nn in the main program.
  • An M99 in a main program loops forever — stop with M30 or a counter.

M-codes vary between machine builders. Codes from M00 to M09, M30 and M98/M99 are nearly universal; most others are defined by the machine builder. Always check the M-code list in your machine manual.

Most-used M-codes

CodeFunction
M00Program Stop
M01Optional Stop
M03Spindle On Clockwise
M04Spindle On Counter-Clockwise
M05Spindle Stop
M06Tool Change
M08Flood Coolant On
M09Coolant Off
M30Program End and Rewind
M98Subprogram Call

Frequently asked questions

What does M99 mean on a CNC machine?
M99 is Subprogram Return / Loop. At the end of a subprogram it returns to the calling program. At the end of a main program it jumps back to the start — used for bar-feeder loops and warm-up programs.