What is the etymology of the 하십시오체 sentence endings?

* ~습니다
* ~습니까
* ~읍시오

Some conjecture on my part: The spelling of the indicative and interrogative endings makes me think that 습 and 니다/니까 were once separate, because the ㅂ is never actually pronounced as ㅂ. But it might have been just a choice made when the orthography was standardised.