# Style sheet for NASM ASM
# Copyright (c) 2001, Aleksandar Veselinovic
# $Id: nasm.ssh,v 1.1.2.2 2007/12/29 01:58:31 mhatta Exp $
#

#
# This file is part of a2ps.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; see the file COPYING.  If not, write to
# the Free Software Foundation, 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
#

style masm is
requires a2ps 4.10

written by "Aleksandar Veselinovic <alexa@galeb.etf.bg.ac.yu>"
version is 1.0
documentation is
   "This style highlights MASM ASM code."
end documentation

alphabets are
   "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_#$%01234567890."
case insensitive

# MASM - Register
# keywords in Plain are
#    ax, bx, cx, dx, si, di, bp, sp, es, ds, ss, cs, ah, bh, ch, dh, al, bl, cl,
#    dl, eax, ebx, ecx, edx, esi, edi, ebp, esp
# end keywords

# MASM - Macro; use Label face
keywords in Label are
   /\\.[[:alpha:]][[:alnum:]_]*/
end keywords

# MASM - Operator
keywords in Keyword_strong are
   and, byte, ptr, codeptr, dataptr, dup, dword, eq, far, fword, ge, gt, high,
   large, le, low, lt, mod, ne, near, not, offset, or, proc, pword, qword, seg,
   short, tbyte, type, word, para
end keywords

# MASM - OpCode: these are current as of the 486
keywords in Keyword are
   aaa, aad, aam, aas, adc, add, and, arpl, bound, bsf, bsr, bswap, bt, btc,
   btr, bts, bswap, bt, btc, btr, bts, call, cbw, cdq, clc, cld, cli, clts,
   cmc, cmp, cmps, cmpsb, cmpsw, cmpsd, cmpxchg, cwd, cwde, daa, das, dec, div,
   enter, hlt, idiv, imul, "in", inc, ins, insb, insw, insd, int, into, invd,
   invlpg, iret, iretd, ja, jae, jb, jbe, jc, jcxz, jecxz, je, jz, jg, jge, jl,
   jle, jna, jnae, jnb, jnbe, jnc, jne, jng, jnge, jnl, jnle, jno, jnp, jns,
   jnz, jo, jp, jpe, jpo, js, jz, jmp, lahf, lar, lea, leave, lgdt, lidt, lgs,
   lss, lfs, lods, lodsb, lodsw, lodsd, loop, loope, loopz, loone, loopne,
   retf, retn, lds, les, lldt, lmsw, lock, lsl, ltr, mov, movs, movsb, movsw,
   movsd, movsx, movzx, mul, neg, nop, not, or, out, outs, outsb, outsw, outsd,
   pop, popa, popd, popf, popfd, push, pusha, pushad, pushf, pushfd, rcl, rcr,
   rol, ror, rep, repe, repz, repne, repnz, ret, sahf, sal, sar, shl, shr, sbb,
   scas, scasb, scasw, scasd, seta, setae, setb, setbe, setc, sete, setg,
   setge, setl, setle, setna, setnae, setnb, setnbe, setnc, setne, setng,
   setnge, setnl, setnle, setno, setnp, setns, setnz, seto, setp, setpe, setpo,
   sets, setz, sgdt, sidt, shld, shrd, sldt, smsw, stc, std, sti, stos, stosb,
   stosw, stosd, str, sub, test, verr, verw, wait, wbinvd, xadd, xchg, xlat,
   xlatb, xor
end keywords

# MASM - OpFloat: floating point coprocessor as of 487
keywords in Keyword are
   f2xm1, fabs, fadd, faddp, fbld, fbstp, fchs, fclex, fnclex, fcom, fcomp,
   fcompp, fcos, fdecstp, fdisi, fndisi, fdiv, fdivp, fdivr, fdivrp, feni,
   fneni, ffree, fiadd, ficom, ficomp, fidiv, fidivr, fild, fimul, fincstp,
   finit, fninit, fist, fistp, fisub, fisubr, fld, fldcw, fldenv, fldlg2,
   fldln2, fldl2e, fldl2t, fldpi, fldz, fld1, fmul, fmulp, fnop, fpatan, fprem,
   fprem1, fptan, frndint, frstor, fsave, fnsave, fscale, fsetpm, fsin,
   fsincos, fsqrt, fst, fstcw, fnstcw, fstenv, fnstenv, fstp, fstsw, fnstsw,
   fsub, fsubp, fsubr, fsubrp, ftst, fucom, fucomp, fucompp, fwait, fxam, fxch,
   fxtract, fyl2x, fyl2xp1,
   /fstsw[ \t]\+ax/,
   /fnstsw[ \t]\+ax/
end keywords

# MASM - Directive
keywords in Keyword_strong are
   align, arg, assume, codeseg, comm,
   const, dataseg, db, dd, df, display, dosseg, dp,
   dq, dt, dw, else, elseif, emul, "end", endif, endm, endp,
   ends, enum, equ, proc, public, publicdll, radix,
   extrn, fardata, global, record, segment, smallstack,
   group, if, if1, if2, ifb, ifdef, ifdif, ifdifi,
   ife, ifidn, ifidni, ifnb, ifndef, include, includlib,
   label, largestack, stack, struc, subttl, title,
   model, name, noemul, union, uses, "version",
   org, flat,
   ".model",
   ".186",
   ".286",
   ".286c",
   ".286p",
   ".287",
   ".386",
   ".386c",
   ".386p",
   ".387",
   ".486",
   ".486c",
   ".486p",
   ".8086",
   ".8087",
   ".alpha",
   ".code",
   ".stack",
   ".data"
end keywords

sequences are
    ";" Comment,
    /^;/ Comment_strong,
    C-string,
    C-char
end sequences

end style
