CNC mill · M-code
M98 / M99: subprogram call and return
M98 calls a subprogram (a separate O-number program) and M99 at its end returns to the line after the call. M99 in a main program loops it. Formats below from Haas and LinuxCNC, each from its maker.
Worked example
Run pocket subprogram O1001 at two offsets. Written for this page in the Haas format.
G54 M98 P1001G55 M98 P1001M30O1001 (pocket)(… cutting moves …)M99How each control writes it
Haas M98 P- L- … M99
One source: Haas Automation, the control's maker
- P
- Program number to call (or a path)
- L
- Repeat count, 1–99 (optional)
- The control looks in the main program's folder, then the path in Setting 251.
- M99 P- jumps to block N- instead; in a main program M99 loops until reset.
Source: Haas Automation, mill M98
LinuxCNC M98 P- L- … M99
One source: the LinuxCNC project, the control's maker
- P
- Program number
- L
- Repeat count (optional)
- Supported for Fanuc-style programs; LinuxCNC's own subroutines use O-word sub/call.
Source: LinuxCNC documentation, "M98 and M99" (archived Oct 24, 2026)
No Fanuc row yet: that chapter of the 0i manual has not been read.
Haas follows Fanuc's numbering, but options and parameters differ between controls: check your control's manual.