Here are the documents that are explaining all the squawk stuff. This is a highly regulated procedure that reaches from the Atlantic to the Pacific trying to make best use of the 4096 squawks available.
(Unfortunately the second document take 200 pages or so)
General rules:
http://www.icao.int/eurnat/edocs/CAL_Ed2_Amd3_PartA.pdf
Table listing of squawk groups:
http://www.icao.int/eurnat/edocs/CAL_Ed2_Amd3_PartB.pdf