The verb "dormir", like all other Spanish verbs, is formed out of a root "d_rm" and one or more suffixes. Depending on whether the root is stressed or not it has two variant forms; when it is stressed it is "dUÉrm-", and when it is unstressed it is "dORm-"(or "dURm-."). In the infinitive "dormir", the stress falls on the syllable -ÍR, the root is unstressed, and we get /dorm/. That is what happens also in "dormMÍmos, "dorMÍS" (present), "dorMÍa" (imperfect), "dorMÍ", "dorMÍSte" (past), "dormiRÉ" (future), "dormiRÍa" (conditional), and "dorMÍdo" (past participle). Unstressed /dorm/ alternates with /durm/ (another weak form) in the gerund "dURmiéndo", in the simple past "durMIÓ" and also in the imperfect subjunctive "durMIÉra", and the present subjunctive "durMÁmos", "durMÁIS", etc., all with stress on the inflectional suffixes; on the contrary, if the root syllable receives stress, short /o/ becomes the diphthong /UÉ/. That is what happens in "dUÉRmo", "dUÉRmes", "dUÉRme", "duÉRmen" (indicative), "duÉRma", "dUÉRmas", "duÉRman" (subjunctive). In the imperative, we have "dUÉRme/a/an" but "dormÍD", under change of stress. The change (stressed /o/ > stressed /we/ is a general rule in the evolution fronm Latin to Spanish, cf. examples like "FÓcus > FUÉgo", "PÓNte" >"PUÉNte", "FÓNte" > "FUÉNte", "PÓRcus" > PUÉRco, "PÓRtus" > "PUÉRto", "HÓRtus" > "HUÉRto", etc.; the same alternation occurs in "PÓdo" > PUÉdo"/"poDÉR", "ROgo" > "RUÉgo"/"roGÁR", and hundreds of similar cases. It may seem a bit complicated, but everything follows from well understood rules, even if lay native speakers have no access to the history of their language and are not aware of them.