We present the atomic model for the hydrogen passivation of DX centers in GaAs and AlxGa1-xAs alloys doped with Si and S donors using an ab initio pseudopotential method. In GaAs, the DX centers with the negative-U property are found to be stabilized at pressures above 22 kbar. Both the shallow donors and deep DX centers are neutralized by hydrogen via the formation of donor-hydrogen complexes which are neutral in a charge state. In AlxGa1-xAs alloys, we study the effects of the Al atoms on the interactions between H and its neighboring atoms. The calculated dissociation energies for the donor-hydrogen complexes agree with measured values.