[Tex/LaTex] x86 Assembly Language Listing

latex3listings

I am trying to make the following x86 Assembly Language Listing style:

x86 Assembly Language Listing

But I couldn't make it. My listing code is as:

\documentclass{article}
\usepackage{listings}
\usepackage{color}
\usepackage{tikz}
\usepackage[utf8]{inputenc} 
\usepackage[T1]{fontenc}


\lstdefinestyle{customasm}{
    belowcaptionskip=1\baselineskip,
    frame=single, 
    frameround=tttt,
    xleftmargin=\parindent,
    language=[x86masm]Assembler,
    basicstyle=\footnotesize\ttfamily,
    commentstyle=\itshape\color{green!60!black},
    keywordstyle=\color{blue!80!black},
    identifierstyle=\color{red!80!black},
    tabsize=4,
    numbers=left,
    numbersep=8pt,
    stepnumber=1,
    numberstyle=\tiny\color{gray}, 
    columns = fullflexible,
}

\begin{document}
    \section*{x86 Listing}
\begin{lstlisting}[style=customasm, caption={x86 Code}, label=x86code]
.MODEL SMALL
.STACK 100H
.CODE

MOV AX, 0x3C
MOV BX, 0000000000001010B
ADD AX, BX
MOV BX, 14
SUB AX, BX

MOV AH, 04CH
INT 21H
\end{lstlisting}
    
\end{document}

listing output

Best Answer

Maybe using the minted package instead of listings would be a solution? The nasm lexer produces output that is very similar to your example.

\documentclass{article}
\usepackage{caption}
\usepackage[newfloat]{minted}
\captionsetup[listing]{position=top}
\begin{document}
\section*{x86 Listing}
\begin{listing}[h]
\caption{x86 Code}
\begin{minted}[linenos,frame=single]{nasm}
.MODEL SMALL
.STACK 100H
.CODE

MOV AX, 0x3C
MOV BX, 0000000000001010B
ADD AX, BX
MOV BX, 14
SUB AX, BX

MOV AH, 04CH
INT 21H
\end{minted}
\end{listing}
    
\end{document}

Result:

enter image description here