G&M Codes make up the most of the contents of the CNC program. The definition of each class of code and specific meanings of the most important codes are covered next.
Codes that begin with G are called preparatory words because they prepare the machine for a certain type of motion. The most common G-codes are shown in Table 5.3 and a complete list and their meaning is included in Appx D - G-M Codes Reference.
![]() |
Note: Older controls required G-codes to be written with a leading zero, like G01. Most machines now allow the leading zero to be omitted, as shown in the table below. |
Code |
Meaning |
G0 | Rapid motion. Used to position the machine for non-milling moves. |
G1 | Line motion at a specified feed rate. |
G2 | Clockwise arc. |
G3 | Counterclockwise arc. |
G4 | Dwell. |
G28 | Return to machine home position. |
G40 | Cutter Diameter Compensation (CDC) off. |
G41 | Cutter Diameter Compensation (CDC) left. |
G42 | Cutter Diameter Compensation (CDC) right. |
G43 | Tool length offset (TLO). |
G54 | Fixture Offset #1. |
G55 | Fixture Offset #2. |
G56 | Fixture Offset #3. |
G57 | Fixture Offset #4. |
G58 | Fixture Offset #5. |
G59 | Fixture Offset #6. |
G80 | Cancel drill cycle. |
G81 | Simple drill cycle. |
G82 | Simple drill cycle with dwell. |
G83 | Peck drill cycle. |
G84 | Tap cycle. |
G90 | Absolute coordinate programming mode. |
G91 | Incremental coordinate programming mode. |
G98 | Drill cycle return to Initial point (R). |
G99 | Drill cycle return to Reference plane (last Z Height) |
Codes that begin with M are called miscellaneous words. They control machine auxiliary options like coolant and spindle direction. Only one M-code can appear in each block of code.
The table below lists the most common M codes and their meaning. A complete list of M-codes is included in Appx D - G-M Codes Reference.
Code |
Meaning |
M0 | Program stop. Press Cycle Start button to continue. |
M1 | Optional stop. Only executed if Op Stop switch on the CNC control is turned ON. |
M2 | End of program. |
M3 | Spindle on Clockwise. |
M4 | Spindle on Counterclockwise. |
M5 | Spindle stop. |
M6 | Change tool. |
M8 | Coolant on. |
M9 | Coolant off. |
M30 | End program and press Cycle Start to run it again. |