Studies of evolved stars. V. Nucleosynthesis in hot-bottom convective envelopes