G-code and M-code list

Every code for a mill and a lathe as Haas publishes them (Haas follows Fanuc's numbering). Codes with a page of their own give the format, each address, a worked example, and how Haas and LinuxCNC differ. To check a program, use the G-code checker.

Mill G-codes

Mill G-codes, as Haas publishes them
CodeWhat it doesGroup
G00Rapid Motion Positioning01
G01Linear Interpolation Motion01
G02Circular Interpolation Motion CW01
G03Circular Interpolation Motion CCW01
G04Dwellone-shot
G09Exact Stopone-shot
G10Set Offsetsone-shot
G12Circular Pocket Milling CWone-shot
G13Circular Pocket Milling CCWone-shot
G17XY Plane Selection02
G18XZ Plane Selection02
G19YZ Plane Selection02
G20Select Inches06
G21Select Metric06
G28Return To Machine Zero Pointone-shot
G29Return From Reference Pointone-shot
G31Feed Until Skipone-shot
G35Automatic Tool Diameter Measurementone-shot
G36Automatic Work Offset Measurementone-shot
G37Automatic Tool Offset Measurementone-shot
G40Cutter Compensation Cancel07
G412D Cutter Compensation Left07
G422D Cutter Compensation Right07
G43Tool Length Compensation + (Add)08
G44Tool Length Compensation - (Subtract)08
G47Text Engravingone-shot
G49G43/G44/G143 Cancel08
G50Cancel Scaling11
G51Scaling11
G52Set Work Coordinate Systemone-shot
G53Non-Modal Machine Coordinate Selectionone-shot
G54Select Work Coordinate System #112
G55Select Work Coordinate System #212
G56Select Work Coordinate System #312
G57Select Work Coordinate System #412
G58Select Work Coordinate System #512
G59Select Work Coordinate System #612
G60Uni-Directional Positioningone-shot
G61Exact Stop Mode15
G64G61 Cancel15
G65Macro Subprogram Call Optionone-shot
G68Rotation16
G69Cancel G68 Rotation16
G70Bolt Hole Circleone-shot
G71Bolt Hole Arcone-shot
G72Bolt Holes Along an Angleone-shot
G73High-Speed Peck Drilling Canned Cycle09
G74Reverse Tap Canned Cycle09
G76Fine Boring Canned Cycle09
G77Back Bore Canned Cycle09
G80Canned Cycle Cancel09
G81Drill Canned Cycle09
G82Spot Drill Canned Cycle09
G83Normal Peck Drilling Canned Cycle09
G84Tapping Canned Cycle09
G85Boring Canned Cycle09
G86Bore and Stop Canned Cycle09
G89Bore In, Dwell, Bore Out Canned Cycle09
G90Absolute Position Command03
G91Incremental Position Command03
G92Set Work Coordinate Systems Shift Valueone-shot
G93Inverse Time Feed Mode05
G94Feed Per Minute Mode05
G95Feed per Revolution05
G98Canned Cycle Initial Point Return10
G99Canned Cycle R Plane Return10
G100Cancel Mirror Imageone-shot
G101Enable Mirror Imageone-shot
G103Limit Block Bufferingone-shot
G107Cylindrical Mappingone-shot
G110#7 Coordinate System12
G111#8 Coordinate System12
G112#9 Coordinate System12
G113#10 Coordinate System12
G114#11 Coordinate System12
G115#12 Coordinate System12
G116#13 Coordinate System12
G117#14 Coordinate System12
G118#15 Coordinate System12
G119#16 Coordinate System12
G120#17 Coordinate System12
G121#18 Coordinate System12
G122#19 Coordinate System12
G123#20 Coordinate System12
G124#21 Coordinate System12
G125#22 Coordinate System12
G126#23 Coordinate System12
G127#24 Coordinate System12
G128#25 Coordinate System12
G129#26 Coordinate System12
G136Automatic Work Offset Center Measurementone-shot
G1413D+ Cutter Compensation07
G1435-Axis Tool Length Compensation +08
G150General Purpose Pocket Millingone-shot
G154Select Work Coordinates P1-P9912
G156Broaching Canned Cycle09
G167Modify Settingone-shot
G174CCW Non-Vertical Rigid Tapone-shot
G184CW Non-Vertical Rigid Tapone-shot
G187Setting the Smoothness Levelone-shot
G234Tool Center Point Control (TCPC)08
G253Orient Spindle Normal To Feature Coordinate Systemone-shot
G254Dynamic Work Offset (DWO)23
G255Cancel Dynamic Work Offset (DWO)23
G266Visible Axes Linear Rapid % Motionone-shot
G268Enable Feature Coordinate System14
G269Disable Feature Coordinate System14

Mill M-codes

Mill M-codes, as Haas publishes them
CodeWhat it doesGroup
M00Stop Program
M01Optional Program Stop
M02Program End
M03Spindle Forward
M04Spindle Reverse
M05Spindle Stop
M06Tool Change
M07Shower Coolant On
M08Coolant On
M09Coolant Off
M10Engage 4th Axis Brake
M11Release 4th Axis Brake
M12Engage 5th Axis Brake
M13Release 5th Axis Brake
M16Tool Change
M19Orient Spindle
M21Optional User M Function with M-Fin
M22Optional User M Function with M-Fin
M23Optional User M Function with M-Fin
M24Optional User M Function with M-Fin
M25Optional User M Function with M-Fin
M29Set Output Relay with M-Fin (Haas); rigid tapping on Fanuc
M30Program End and Reset
M31Chip Conveyor Forward
M33Chip Conveyor Stop
M34Coolant Increment
M35Coolant Decrement
M36Pallet Part Ready
M39Rotate Tool Turret
M41Low Gear Override
M42High Gear Override
M46Jump to Line
M48Validate Program for Loaded Pallet
M50Pallet Change Sequence
M51Set Optional User M-codes
M52Set Optional User M-codes
M53Set Optional User M-codes
M54Set Optional User M-codes
M55Set Optional User M-codes
M59Set Output Relay
M61Clear Optional User M-codes
M62Clear Optional User M-codes
M63Clear Optional User M-codes
M64Clear Optional User M-codes
M65Clear Optional User M-codes
M69Clear Output Relay
M70Workholding Clamp
M71Workholding Unclamp
M73Tool Air Blast On
M74Tool Air Blast Off
M75Set G35 or G136 Reference Point
M78Alarm if Skip Signal Found
M79Alarm if Skip Signal Not Found
M80Auto Door Open
M81Auto Door Close
M82Tool Unclamp
M83Auto Air Gun On
M84Auto Air Gun Off
M86Tool Clamp
M88Through-Spindle Coolant On
M89Through-Spindle Coolant Off
M90Fixture Clamp Input On
M91Fixture Clamp Input Off
M95Sleep Mode
M96Jump If No Input
M97Local Sub-Program Call
M98Sub-Program Call
M99Sub-Program Return or Loop
M104Probe Arm Extend
M105Probe Arm Retract
M109Interactive User Input
M116Vise Air Chips Blast On
M117Vise Air Chips Blast Off
M130Display Media
M131Cancel Display Media
M138Spindle Speed Variation On
M139Spindle Speed Variation Off
M158Mist Condenser On
M159Mist Condenser Off
M160Cancel Active PulseJet
M161PulseJet Continuous Mode
M162PulseJet Single Event Mode
M163PulseJet Modal Mode
M180Auto Window Open
M181Auto Window Close
M199Pallet / Part Load or Program End
M300APL/Robot Custom Sequence

Lathe G-codes

Lathe G-codes, as Haas publishes them
CodeWhat it doesGroup
G00Rapid Motion Positioning01
G01Linear Interpolation Motion01
G02CW Circular Interpolation Motion01
G03CCW Circular Interpolation Motion01
G04Dwellone-shot
G09Exact Stopone-shot
G10Set Offsetsone-shot
G12Circular Pocket Milling CW
G13Circular Pocket Milling CCW
G14Secondary Spindle Swap17
G15Secondary Spindle Swap Cancel17
G17XY Plane02
G18XZ Plane02
G19YZ Plane02
G20Select Inches06
G21Select Metric06
G28Return To Machine Zero Pointone-shot
G29Return From Reference Pointone-shot
G31Skip Functionone-shot
G32Thread Cutting01
G40Tool Nose Compensation Cancel07
G41Tool Nose Compensation (TNC) Left07
G42Tool Nose Compensation (TNC) Right07
G43Tool Length Compensation + (Add)08
G47Text Engravingone-shot
G50Spindle Speed Limitone-shot
G51Set Global coordinate Offset FANUCone-shot
G52Set Local Coordinate System FANUCone-shot
G53Machine Coordinate Selectionone-shot
G54Coordinate System #1 FANUC12
G55Coordinate System #2 FANUC12
G56Coordinate System #3 FANUC12
G57Coordinate System #4 FANUC12
G58Coordinate System #5 FANUC12
G59Coordinate System #6 FANUC12
G61Exact Stop Modal15
G64Exact Stop Cancel G6115
G65Macro Subprogram Call Optionone-shot
G68Rotation16
G69Cancel G68 Rotation16
G70Finishing Cycleone-shot
G71O.D./I.D. Stock Removal Cycleone-shot
G72End Face Stock Removal Cycleone-shot
G73Irregular Path Stock Removal Cycleone-shot
G74End Face Grooving Cycleone-shot
G75O.D./I.D. Grooving Cycleone-shot
G76Threading Cycle, Multiple Passone-shot
G80Canned Cycle Cancel09
G81Drill Canned Cycle09
G82Spot Drill Canned Cycle09
G83Normal Peck Drilling Canned Cycle09
G84Tapping Canned Cycle09
G85Boring Canned Cycle09
G86Bore and Stop Canned Cycle09
G89Bore and Dwell Canned Cycle09
G90O.D./I.D. Turning Cycle01
G92Threading Cycle01
G94End Facing Cycle01
G95Live Tooling Rigid Tap (Face)09
G96Constant Surface Speed On13
G97Constant Surface Speed Off13
G98Feed Per Minute10
G99Feed Per Revolution10
G100Disable Mirror Imageone-shot
G101Enable Mirror Imageone-shot
G103Limit Block Lookaheadone-shot
G105Servo Bar Command09
G107Cylindrical Mappingone-shot
G110Coordinate System #712
G111Coordinate System #812
G112XY to XC Interpolation04
G113Cancel G11204
G114Coordinate System #912
G115Coordinate System #1012
G116Coordinate System #1112
G117Coordinate System #1212
G118Coordinate System #1312
G119Coordinate System #1412
G120Coordinate System #1512
G121Coordinate System #1612
G122Coordinate System #1712
G123Coordinate System #1812
G124Coordinate System #1912
G125Coordinate System #2012
G126Coordinate System #2112
G127Coordinate System #2212
G128Coordinate System #2312
G129Coordinate System #2412
G154Select Work Coordinates P1-9912
G156Broaching Canned Cycle09
G167Modify Settingone-shot
G170Cancel G171/G17220
G171Radius Programming Override20
G172Diameter Programming Override20
G184Reverse Tapping Canned Cycle For Left Hand Threads09
G186Reverse Live Tool Rigid Tap (For Left Hand Threads)09
G187Accuracy Controlone-shot
G195Forward Live Tool Radial Tapping (Diameter)09
G196Reverse Live Tool Radial Tapping (Diameter)09
G198Disengage Synchronous Spindle Controlone-shot
G199Engage Synchronous Spindle Controlone-shot
G200Index on the Flyone-shot
G211Manual Tool Setting
G212Auto Tool Setting
G234Tool Center Point Control (TCPC)08
G241Radial Drill Canned Cycle09
G242Radial Spot Drill Canned Cycle09
G243Radial Normal Peck Drilling Canned Cycle09
G245Radial Boring Canned Cycle09
G246Radial Bore and Stop Canned Cycle09
G249Radial Bore and Dwell Canned Cycle09
G250Cancel Scaling11
G251Scaling11
G254Dynamic Work Offset (DWO)23
G255Cancel Dynamic Work Offset (DWO)23
G266Visible Axes Linear Rapid %Motionone-shot
G268Enable Feature Coordinate System02
G269Disable Feature Coordinate System02
G390Absolute Position Command03
G391Incremental Position Command03

Lathe M-codes

Lathe M-codes, as Haas publishes them
CodeWhat it doesGroup
M00Stop Program
M01Optional Stop Program
M02Program End
M03Spindle On Forward
M04Spindle On Reverse
M05Spindle Stop
M08Coolant On
M09Coolant Off
M10Chuck Clamp
M11Chuck Unclamp
M12Auto Jet Air Blast On
M13Auto Jet Air Blast Off
M14Main Spindle Brake On
M15Main Spindle Brake Off
M17Turret Rotation Forward
M18Turret Rotation Reverse
M19Orient Spindle
M21Tailstock Advance
M22Tailstock Retract
M23Chamfer Out of Thread On
M24Chamfer Out of Thread Off
M30End of Program and Reset
M31Chip Auger Forward
M33Chip Auger Stop
M35Parts Catcher Part-Off Position
M36Parts Catcher On
M37Parts Catcher Off
M38Spindle Speed Variation On
M39Spindle Speed Variation Off
M41Low Gear
M42High Gear
M43Turret Unlock (Service Use Only)
M44Turret Lock (Service Use Only)
M51Turn On Built-In M-Code Relay
M52Turn On Built-In M-Code Relay
M53Turn On Built-In M-Code Relay
M54Turn On Built-In M-Code Relay
M55Turn On Built-In M-Code Relay
M56Turn On Built-In M-Code Relay
M59Turn On Output Relay
M61Turn Off Built-In M-Code Relay
M62Turn Off Built-In M-Code Relay
M63Turn Off Built-In M-Code Relay
M64Turn Off Built-In M-Code Relay
M65Turn Off Built-In M-Code Relay
M66Turn Off Built-In M-Code Relay
M69Turn Off Output Relay
M78Alarm if Skip Signal Found
M79Alarm if Skip Signal Not Found
M85Automatic Door Open
M86Automatic Door Close
M88High Pressure Coolant On
M89High Pressure Coolant Off
M90Fixture Clamp Input On
M91Fixture Clamp Input Off
M95Sleep Mode
M96Jump If No Signal
M97Local Subprogram Call
M98Subprogram Call
M99Subprogram Return Or Loop
M104Probe Arm Extend
M105Probe Arm Retract
M109Interactive User Input
M110Secondary Spindle Chuck Clamp
M111Secondary Spindle Chuck Unclamp
M112Secondary Spindle Air Blast On
M113Secondary Spindle Air Blast Off
M114Secondary Spindle Brake On
M115Secondary Spindle Brake Off
M119Secondary Spindle Orient
M121Built-In M-Code Relays with M-Fin
M122Built-In M-Code Relays with M-Fin
M123Built-In M-Code Relays with M-Fin
M124Built-In M-Code Relays with M-Fin
M125Built-In M-Code Relays with M-Fin
M126Built-In M-Code Relays with M-Fin
M129Turn On M-Code Relay with M-Fin
M130Display Media
M131Cancel Display Media
M133Live Tool Forward
M134Live Tool Reverse
M135Live Tool Stop
M138Spindle Speed Variation On
M139Spindle Speed Variation Off
M143Secondary Spindle Forward
M144Secondary Spindle Reverse
M145Secondary Spindle Stop
M146Steady Rest Clamp
M147Steady Rest Unclamp
M158Mist Condenser On
M159Mist Condenser Off
M170Engage 4th Axis Brake
M171Release 4th Axis Brake
M214Live Tool Brake On
M215Live Tool Brake Off
M219Live Tool Orient
M299APL / Part Load / or Program End
M300APL/Robot Custom Sequence
M334P-Cool Increment
M335P-Cool Decrement
M373Tool Air Blast On
M374Tool Air Blast Off
M388Through-Spindle Coolant On
M389Through-Spindle Coolant Off
Sources4