A high-resolution Ramsey-Bordé spectrometer for optical clocks based on cold Mg atoms