Orbital quantization of electronic states in a magnetic field as the origin of second-harmonic generation in diamagnetic semiconductors