# Using minted for assembly code

I want to use minted to display code that I have disassembled in X86 assembly code.

\documentclass[11pt,letterpaper]{article}
\usepackage{minted}

\begin{document}

\begin{minted}{gas}
0000000000400566 <main>:
400566:   55                      push   %rbp
400567:   48 89 e5                mov    %rsp,%rbp
40056a:   48 83 ec 20             sub
\end{minted}

\end{document}


How can I get rid of the red boxes around the instructions?

• the red box is the style that pygments uses for (what it thinks are) syntax errors. Is it expecting output from a different dissasembler (or its lexer can be simply wrong) – David Carlisle Oct 19 '17 at 22:03
• It is because normally in assembly code, you don't specify the addresses of instructions. Here, I have them because I disassembled the code and this is the output from the disassembler. – edkeveked Oct 19 '17 at 22:10
• well... there are other assembly language lexers for pygments other than gsm is one of them suitable? or you could define a new pygments style at the python side or try to patch in a redefinition of the error box at the tex side (but that's a bit fragile in minted) – David Carlisle Oct 19 '17 at 22:20
• Your example just makes ! LaTeX Error: Environment myminted undefined. – David Carlisle Oct 19 '17 at 22:24

The "proper" way to do this would be to make a modified pygmentize lexer on the python side so these are not classed as errors, but simpler, as the only use of \fcolorbox is to make these boxes is to redefine it to do something else:

\documentclass[11pt,letterpaper]{article}
\usepackage{minted}

\begin{document}

{\renewcommand\fcolorbox[4][]{\textcolor{cyan}{\strut#4}}
\begin{minted}{gas}
0000000000400566 <main>:
400566:   55                      push   %rbp
400567:   48 89 e5                mov    %rsp,%rbp
40056a:   48 83 ec 20             sub
\end{minted}
}

\end{document}

• It is a shortcut that solve my problem a little bit, though it is strange that the same address is colored with different colors. – edkeveked Oct 19 '17 at 22:42
• @edkeveked you can look at the parsed file (the one with the long name in the minted directory) to see what the gsm lexer thought the various tokens were but since it is trying to parse a file with a different syntax the output is always going to be a bit odd, you could make the \fcolorbox redefinition redefine \color locally inside the \textcolor then at least the nested a wouldn't get a colour change – David Carlisle Oct 19 '17 at 23:07