This should be in your programming manuals for the machine. I have used a few different M codes on different machines I've had to control it. M50, M60, M51, M52, M61, M62. The pallet changer will typically run off of a 9000 series program. Look through your program list and see if you can determine which program is controlling the functions. Then there are parameters that control the M code calling that program. On newer controls (16, 18, 21i) these paramters are 6071 calls 9001, 6072 calls 9002, 6073 for 9003, etc up to parameter 6089 that calls 9029.
I also have one machine that uses a rack and pinion hydraulic indexer, the M code only sends up flags in the ladder and doesn't trigger a program to control the function. If you have a servo motor connected to the indexer it's more than likely that one of your 9000 series programs should control it. If it is all hydraulic, it may be a little harder to determine, but with some searching in the ladder you should be able to find the M code.
(Note: The opinions expressed in this post are my own and are not necessarily those of cnc-professional-forum.com and its management)