I know how to do it (and custom G codes) but only on Fanuc 16, 18, 21 and their variants.
With the parameter write enabled, you have to first decide which you want, M code or G code. Then you go into a small group of parameters and enter the 2, 3, or 4-digit code you want associated with a particular O9000-series program.
I raise a BIG CAUTION: if there is ANY value in any of those parameters, LEAVE IT!
If there's already a value from the machine tool builder and you go and change it, you'll screw up something and it could be very dangerous. If you accidentally delete a value, some function of the machine will longer longer work. The same is true of the "9000 series" macro programs executed by the G and M codes you wish to create. If you've disabled the "write protect" of 3202.4, you could
easily wreak havoc on your machine tool builder's programs! Back up EVERYTHING before editing ANYTHING.
6050 = G code that calls the custom macro of program number 9010
6051 = G code that calls the custom macro of program number 9011
6052 = G code that calls the custom macro of program number 9012
6053 = G code that calls the custom macro of program number 9013
6054 = G code that calls the custom macro of program number 9014
6055 = G code that calls the custom macro of program number 9015
6056 = G code that calls the custom macro of program number 9016
6057 = G code that calls the custom macro of program number 9017
6058 = G code that calls the custom macro of program number 9018
6059 = G code that calls the custom macro of program number 9019
6071 = M code that calls the custom macro of program number 9001
6072 = M code that calls the custom macro of program number 9002
6073 = M code that calls the custom macro of program number 9003
6074 = M code that calls the custom macro of program number 9004
6075 = M code that calls the custom macro of program number 9005
6076 = M code that calls the custom macro of program number 9006
6077 = M code that calls the custom macro of program number 9007
6078 = M code that calls the custom macro of program number 9008
6079 = M code that calls the custom macro of program number 9009
6080 = M code that calls the custom macro of program number 9020
6081 = M code that calls the custom macro of program number 9021
6082 = M code that calls the custom macro of program number 9022
6083 = M code that calls the custom macro of program number 9023
6084 = M code that calls the custom macro of program number 9024
6085 = M code that calls the custom macro of program number 9025
6086 = M code that calls the custom macro of program number 9026
6087 = M code that calls the custom macro of program number 9027
6088 = M code that calls the custom macro of program number 9028
6089 = M code that calls the custom macro of program number 9029
Use these very carefully, and DO NOT blame me if you screw up your machine.