M-code reference

M99: Subprogram end / return

M99 is subprogram end / return. Ends a subprogram and returns to the calling program. It is non-modal, so it acts only on the line it is written on.

What M99 does

M99 at the end of a subprogram returns control to the line after the M98 that called it. In a main program, M99 loops back to the start, which some bar-fed lathes use to run continuously.

TypeM-code
MachineMill and lathe
GroupProgram control
ModalNo: acts only on its own line

M99 example

M99

Return to the calling program.

WordWhat it means here
M99Subprogram end / return

Codes people confuse with M99

CodeWhat it does instead
M98 Subprogram call. Calls another program as a subprogram.
M30 End of program and rewind. Ends the program and returns to the first line, ready for the next part.

Other codes in the program control group

These also act only on their own line.

  • M00 Program stop
  • M01 Optional stop
  • M02 End of program
  • M30 End of program and rewind
  • M97 Local subprogram call (Haas)
  • M98 Subprogram call

Meanings follow the common Fanuc-style standard that Haas, Okuma (EIA mode), Mitsubishi, LinuxCNC and most other controls share for this code. Options and parameters change details from machine to machine, so check the manual for your control.

Quick check: M99

  1. What does M99 do? (Mill and lathe)

  2. Which code: Ends a subprogram and returns to the calling program.(Mill and lathe)

  3. What does M98 do? (Mill and lathe)

Show the answers
  1. Ends a subprogram and returns to the calling program.
  2. M99
  3. Calls another program as a subprogram.

Drill this code with the rest of the core set

More practice hubs

Frequently asked questions

What does M99 mean in CNC programming?
Subprogram end / return. Ends a subprogram and returns to the calling program.
Is M99 modal?
No. M99 acts only on the line where it is written; the next line goes back to whatever modal codes were already active.
What is the difference between M99 and M98?
M99 (subprogram end / return): ends a subprogram and returns to the calling program. M98 (subprogram call): calls another program as a subprogram.
What is the difference between M99 and M30?
M99 (subprogram end / return): ends a subprogram and returns to the calling program. M30 (end of program and rewind): ends the program and returns to the first line, ready for the next part.

G-Code Sprint is an educational practice tool only. It is not a CNC simulator, machine controller, safety manual, or replacement for instruction. Always follow your instructor, employer, machine manual, and shop procedures.

Free preview · no card Try G-Code Sprint