Printed from Kezuriba (kezuriba.net/en/nc/m99/)
M99
Machining center, LatheSubprogram end (return to the caller)
Format and notes
M99 (M99 P_ specifies the sequence number to return to)
- Writing M99 in a main program returns to the top and repeats it (Siemens ISO, Haas)
- M99 P_ can resume from the specified sequence number it returns to
M00–M02, M30, M98 and M99 stop, end or call programs, and their meaning is almost the same in all the sources we checked (sources that differ are listed in the table below). M98 and M99 are handled inside the CNC (the Siemens ISO dialect manual treats M90–M99 as CNC-internal). Most other M codes are assigned by the machine builder.
Full guide with examples: Intro to custom macros and subprograms (M98, M99, G65, # variables)
Try it in the simulator (machining center)
M98 P2000 L3 calls subprogram O2000 three times and M99 returns. Inside it is incremental (G91), so each call moves 15 mm in X.
Simulator with exercises: Machining center page
Frequently asked questions about M99
- What is M99 (Subprogram end (return to the caller)) used for and how is it formatted in a CNC program?
- M99 commands "Subprogram end (return to the caller)" on Machining center, Lathe. The standard program format is "M99 (M99 P_ specifies the sequence number to return to)". Writing M99 in a main program returns to the top and repeats it (Siemens ISO, Haas)
- Is M99 a modal code or a one-shot (non-modal) code?
- Whether M99 acts modally or as a single-block command depends on the CNC control and the machine builder’s PLC ladder implementation. Check your machine’s active modal status screen and programming manual before running in auto mode.
- Does M99 work differently on machining centers (mills) versus CNC lathes?
- M99 is primarily used on Machining center, Lathe. Depending on the machine type and the lathe G-code system (System A, B, or C), this code may be unavailable or assigned to a different function, so verify against your machine tool manual.
- Are there differences in M99 across FANUC, Mitsubishi, Okuma, Haas, and Siemens controls?
- While the core behavior of M99 is shared across most ISO-compatible CNC controls (FANUC, Mitsubishi Electric, Haas), controls using native conversational or proprietary dialects (such as Okuma OSP, Siemens native mode, or Heidenhain) or machine-specific M-code tables may use different syntax. Always verify with single-block execution and distance-to-go display on a new machine.
Sources
The meaning of this code agrees in two or more sources from different publishers. Explanations are written in our own words.
- Siemens AG — SINUMERIK 802D sl/840D/840D sl/840Di/840Di sl/810D Programming Manual ISO Milling, 04.2007 Edition (6FC5398-7BP10-0BA0) cache.industry.siemens.com
- Haas Automation, Inc. — Mill Operator's Manual – 18 Mill M-Codes (online version) haascnc.com
- Haas Automation, Inc. — Lathe Operator's Manual – 17 Lathe M-Codes (online version) haascnc.com