You may try parcolumns package.
See also other question: Of parallel texts, lists and display equations.
Example
\documentclass[12pt]{article}
\usepackage[a4paper,margin=1cm]{geometry}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[scaled=0.82]{beramono}
\usepackage{pifont,calc,xcolor}
\usepackage{parcolumns}
\usepackage{listings}
\definecolor{verylightgray}{gray}{0.85}
\newlength\lsthorizontalpadding
\setlength\lsthorizontalpadding{3pt}
\newcommand*\lstnumberstyle{\ttfamily\scriptsize}
\newlength\lstnumbersep
\setlength\lstnumbersep{10pt}
\newlength\lstnumberwidth
\setlength\lstnumberwidth{\widthof{\lstnumberstyle00}+\lstnumbersep+\lsthorizontalpadding}
\lstset{
,basicstyle=\ttfamily%
,breaklines=true%
,tabsize=4%
,showstringspaces=false%
,numbers=left%
,numbersep=\lstnumbersep%
,numberstyle=\lstnumberstyle%
,framesep=0pt%
,xleftmargin=\lstnumberwidth%
,framexleftmargin=\lsthorizontalpadding%
,xrightmargin=\lsthorizontalpadding%
,framexrightmargin=\lsthorizontalpadding%
,backgroundcolor=\color{verylightgray}%
,postbreak=\ding{229}\space%
}
%% far from complete list of gasm-specific keywords and instructions in AT&T syntax
\lstdefinelanguage[x86gasm]{Assembler}[x86masm]{Assembler}{%
,morekeywords={rax,rbx,rcx,rdx,rip,rdi,rsi,rsp,subq,decl,movq,movl,xorl,imull,popq}%
,morekeywords=[2]{.file,.section,.string,.text,.globl,.cfi_startproc,.cfi_def_cfa_offset,.cfi_endproc,.size,.ident}%
}
\lstnewenvironment{ccol}[1][]{\lstset{language=c,#1}}{}
\lstnewenvironment{acol}[1][]{\lstset{language=[x86gasm]Assembler,#1}}{}
\pagestyle{empty}
\parindent=0pt
\begin{document}
\texttt{gcc} on \texttt{text.c} file (left side) [\texttt{gcc -S -Os text.c}] gives following assembler code (right side):
\begin{parcolumns}{2}
\colchunk[1]{\begin{ccol}
#include <stdio.h>
int main(int argc, char *argv[])
{
int t;
if (argc < 2) {
fprintf(stderr, "Not enough arguments!\n");
return 1;
}
t = atoi(argv[1]);
printf("%d^2 = %d\n", t, t * t);
return 0;
}
\end{ccol}}
\colchunk[2]{\begin{acol}
.file "test.c"
.section .rodata.str1.1,"aMS",@progbits,1
.LC0:
.string "Not enough arguments!\n"
.LC1:
.string "%d^2 = %d\n"
.text
.globl main
.type main, @function
main:
.LFB0:
.cfi_startproc
subq $8, %rsp
.cfi_def_cfa_offset 16
decl %edi
jg .L2
movq stderr(%rip), %rsi
movl $.LC0, %edi
call fputs
movl $1, %eax
jmp .L3
.L2:
movq 8(%rsi), %rdi
xorl %eax, %eax
call atoi
movl %eax, %edx
movl %eax, %esi
movl $.LC1, %edi
imull %eax, %edx
xorl %eax, %eax
call printf
xorl %eax, %eax
.L3:
popq %rdx
ret
.cfi_endproc
.LFE0:
.size main, .-main
.ident "GCC: (Debian 4.4.5-8) 4.4.5"
.section .note.GNU-stack,"",@progbits
\end{acol}}
\end{parcolumns}
\end{document}
