From the mach3 manual
https://machmotion.com/documentation/gcode/Mach3-GCode-Language-Reference.pdf
10.8.7 Call subroutine - M98
This has two formats:
(a) To call a subroutine program within the current part program file code M98 P~ L~ or
M98 ~P ~Q The program must contain an O line with the number given by the P word of
the Call . This O line is a sort of "label" which indicates the start of the subroutine. The O
line may not have a line number (N word) on it. It, and the following code, will normally be
written with other subroutines and follow either an M2, M30 or M99 so it is not reached
directly by the flow of the program.
(b) To call a subroutine which is in a separate file code M98(filename)L~
for example M98 (test.tap)
For both formats:
The L word (or optionally the Q word) gives the number of times that the subroutine is to
be called before continuing with the line following the M98. If the L (Q) word is omitted
then its value defaults to 1.
By using parameters values or incremental moves a repeated subroutine can make several
roughing cuts around a complex path or cut several identical objects from one piece of
material.
Subroutine calls may be nested. That is to say a subroutine may contain a M98 call to
another subroutine. As no conditional branching is permitted it is not meaningful for
subroutines to call themselves recursively.