The electronic structure and magnetic coupling in La2CUO4 and Nd2CUO4 have been analyzed using the results of all-valence-electron calculations for (Cu2O11)18-, (Cu4O12)16-, and (Cu4O20)32- clusters, and their p- and n-doped variants, embedded in a Madelung potential to represent the crystal environment. The calculations employ the semiempirical incomplete neglect of differential overlap (INDO) method, which is parametrized on the basis of atomic and molecular spectroscopic data, but which makes use of no data from copper oxide materials. The energies of the low-lying cluster spin states are fitted to a Heisenberg Hamiltonian and yield values of J (134 meV for La2CuO4 and 117 meV for Nd2CuO4) in close agreement with experiment. The evaluation of J can be compactly represented in terms of the parameters (t, U, and V) of a one-band Hamiltonian that controls resonance among covalent and ionic valence-bond structures. The resonance mixing is achieved by configuration interaction (CI) among valence-band structures defined in terms of localized molecular orbitals (LMO's) obtained from self-consistent field (SCF) INDO calculations. P doping is found to involve strong hybridization of the 2psigma orbitals of the in-plane oxygen ions and the 3d(x2-y2) orbitals of the Cu ions, and the resulting holes are predominantly (approximately 60%) located in the 2psigma orbitals. The lowest-energy n-doped cluster states involve addition of electrons to the 4s/4p Cu atom manifolds. However, the separation of these states from low-spin (3d10) alternatives is uncertain because of apparent sensitivity to the representation of the crystal potential, as found by Martin.