G codes and prepatpry codes which propt axis movement. M codes are misc codes which do little things such as switch tools in the tool magazine or carousel, or turn the spindle on/off. Then you need to specify modal or non-modal for each code. Modal means the code stays active until cancelled by another code, non-modal means code only applies to that exact opperation, and will be cancelled by the next line of code. This is important when you program rapid traverse and such so that you don't mistakenly rapid traverse while the cutter is in the workpiece.

There are online sources that list all of the codes for you. It sounds complicated, but it really isnt too bad once you get the hang of it. And also, once you master the G and M codes, try to move up to a CAD CAM system, where you simply draw the part in a CAD system in 3D solid model, the computer then automatically writes the code for you. This is the easiest way to do it, but it is still good to know the G and M codes so that you can over-ride any problems that may arise.