Mass spectrometric study of ion-pair processes in diatomic molecules: H2, CO, NO and O2