Listings package: how to suppress highlighting/emphasis on identifiers containing keywords?

I'm using the x86masm dialect of Assembler and register names are emphasized even when they occur inside of a label or a hexadecimal number. For example, dh is register, but 0dh is a number, yet the dh part of it is emphasized. I haven't had this problem in listings with any other languages, so I'm assuming it's a problem with the language definition. Is there simple way to redefine the language so that this doesn't happen?

\documentclass[12pt]{article}
\usepackage{courier, listings}

\lstset{
language={[x86masm]Assembler},
basicstyle=\ttfamily\small,
frame=single
}

\begin{document}
\begin{lstlisting}
cmp al, 0dh ; dh = register, 0dh = number
je somewhere
\end{lstlisting}

\end{document}

-

use deletekeywords=.... However, you should use another monotypefont like beramono. Courier is not a good looking mono font.

\documentclass[12pt]{article}
\usepackage{courier, listings}

\lstset{
language={[x86masm]Assembler},
basicstyle=\ttfamily\small,
frame=single,
deletekeywords={dh}
}

\begin{document}
\begin{lstlisting}
cmp al, 0dh ; dh = register, 0dh = number
je somewhere
\end{lstlisting}

\end{document}

-
I might still use the dh register somewhere else, and I'd want it emphasized there. Also, this happens with a lot of other registers (bh, ah, ch), and labels are even more likely to have mnemonics in them, so I might as well remove all highlighting if I'm gonna do it this way. –  Adrian Sep 14 '11 at 14:26
@Herbert: I think the problem is that the OP wants the register dh highlighted, but does not want it highlighted in the number 0dh. Seems that to get a complete general solution, the package would be required to parse the actual language to do that as opposed to just match keywords. –  Peter Grill Sep 14 '11 at 16:15
I did some more tests, and this is a listings problem, not just a problem with the language definition. It only happens with literals starting with digits, ending in a keyword, and containing no other letters. This problem is much more likely to occur in assembly than in other languages because of the short mnemonic names and ubiquity of hexadecimal numbers. –  Adrian Sep 14 '11 at 16:40
Okay, I was able to solve this by turning on case sensitivity and making all hexadecimal digits uppercase. –  Adrian Sep 14 '11 at 16:50
@Adrian: Your last two comments might be worth to be given as an answer: They give some more hints about the root of the problem and provide a reasonable workaround. (Note that it is perfectly acceptable to answer your own questions, other members might profit from your solution!) –  Daniel Sep 14 '11 at 19:25
show 1 more comment

Because the x86masm dialect of the Assembler language considers 0-9 as "digits", not as "letters", listings recognises the keyword dh in 0dh, which, as you pointed out, is undesirable. You can prevent that from happening by making 0-9 "letters". That way, dh will be highlighted as keyword, but 0dh won't.

\documentclass[12pt]{article}
\usepackage{courier, listings}

\lstset{
language=[x86masm]Assembler,
basicstyle=\ttfamily\small,
frame=single,
alsoletter=0123456789,
}

\begin{document}
\begin{lstlisting}
cmp al, 0dh ; dh = register, 0dh = number
je somewhere
dh 0dh; test
\end{lstlisting}
\end{document}

-