Using the following structure, how can I get the listing to stay on the same page, be it at the top or the bottom?
\documentclass{scrartcl}
\usepackage[ngerman]{babel}
\usepackage{multicol}
\usepackage{listings}
\usepackage{lipsum}
\begin{document}
\begin{multicols}{2}
\lipsum[1]
\begin{lstlisting}[float=*htp, frame=tb]
very
long
listing
spanning
several
lines
\end{lstlisting}
\lipsum[2-7]
\end{multicols}
\end{document}

multicolsare only "full line" and always go on the following page. Put thelstlistingenvironment earlier in the input. – egreg Jul 29 '11 at 14:29