To include code listing as figures (including label and caption fields) in LaTeX you can do the following:
\usepackage{caption
...
\noindent\begin{minipage}{\textwidth}
\begin{lstlisting}
hello world!! here the code.
\end{lstlisting}
\captionof{figure}{a caption text.}
\label{fig:figurelabel}
\end{minipage}