<settings>
language=x86 Assembly Language
compiler=
debugger=
execution=
auto_indent=1
use_spaces=0
tab_stop=4
</settings>

<extensions>
 <item name="x86 Assembler Source" ext="x86">
 <item name="Assembler Source" ext="asm">
</extensions>

<syntax>
 <item name="string1" start="\"" end="\"" color="string">
 <item name="string2" start="\'" end="\'" color="string">
 <item name="comment" start=";" end="\n" color="comment">
</syntax>

<pattern>
 <item name="defs" words="^#\ *\t*\(include\|if\|ifdef\|ifndef\|else\|elif\|define\|endif\|pragma\)\b" color="preprocessor">
 <item name="80186set" words="\b\(bound\|enter\|imul\|insb\|insw\|leave\|outsb\|outsw\|popa\|pusha\)\b" color="keyword">
 <item name="80186SET" words="\B\(BOUND\|ENTER\|IMUL\|INSB\|INSW\|LEAVE\|OUTSB\|OUTSW\|POPA\|PUSHA\)\b" color="keyword">
 <item name="80286set" words="\b\(arpl\|clts\|lar\|lgdt\|lidt\|lldt\|lmsw\|lsl\|ltr\|pushw\|sgdt\|sidt\|sldt\|smsw\|str\|verr\|verw\)\b" color="keyword">
 <item name="80286SET" words="\B\(ARPL\|CLTS\|LAR\|LGDT\|LIDT\|LLDT\|LMSW\|LSL\|LTR\|PUSHW\|SGDT\|SIDT\|SLDT\|SMSW\|STR\|VERR\|VERW\)\b" color="keyword">
 <item name="80287set" words="\b\(fsetpm\)\b" color="keyword">
 <item name="80287SET" words="\B\(FSETPM\)\b" color="keyword">
 <item name="80386set" words="\b\(bsf\|bsr\|bt\|btc\|btr\|bts\|cdq\|cmpsd\|cwde\|insd\|iretd\|lfs\|lgs\|lodsd\|lss\|movsd\|movsx\|movzx\|outsd\|popad\|popfd\|pushad\|pushd\|pushfd\|scasd\|set\|shld\|shrd\|stosd\)\b" color="keyword">
 <item name="80386SET" words="\B\(BSF\|BSR\|BT\|BTC\|BTR\|BTS\|CDQ\|CMPSD\|CWDE\|INSD\|IRETD\|LFS\|LGS\|LODSD\|LSS\|MOVSD\|MOVSX\|MOVZX\|OUTSD\|POPAD\|POPFD\|PUSHAD\|PUSHD\|PUSHFD\|SCASD\|SET\|SHLD\|SHRD\|STOSD\)\b" color="keyword">
 <item name="80387set" words="\b\(fcos\|fprem1\|fsin\|fsincos\|fucom\|fucomp\|fucompp\)\b" color="keyword">
 <item name="80387SET" words="\B\(FCOS\|FPREM1\|FSIN\|FSINCOS\|FUCOM\|FUCOMP\|FUCOMPP\)\b" color="keyword">
 <item name="80486set" words="\b\(bswap\|cmpxchg\|invd\|invlpg\|wbinvd\|xadd\)\b" color="keyword">
 <item name="80486SET" words="\B\(BSWAP\|CMPXCHG\|INVD\|INVLPG\|WBINVD\|XADD\)\b" color="keyword">
 <item name="8086set" words="\b\(aaa\|aam\|aas\|adc\|add\|and\|call\|cbw\|clc\|cld\|cli\|cmc\|cmp\|cmpsb\|cmpsw\|cwd\|daa\|das\|dec\|div\|fwait\|hlt\|idiv\|in\|inc\|int\|into\|iret\|j\|jcxz\|jmp\|je\|jl\|jg\|jne\|lahf\|lds\|lea\|les\|lock\|lodsb\|lodsw\|loop\|loope\|loopne\|loopnz\|loopz\|mov\|movsb\|movsw\|mul\|neg\|nop\|not\|or\|out\|pop\|popf\|push\|pushf\|rcl\|rcr\|rep\|repe\|repne\|repnz\|repz\|ret\|rol\|ror\|sahf\|sal\|sar\|sbb\|scasb\|scasw\|shl\|shr\|stc\|std\|sti\|stosb\|stosw\|sub\|test\|wait\|xchg\|xlat\|xor\)\b" color="keyword">
 <item name="8086SET" words="\B\(AAA\|AAM\|AAS\|ADC\|ADD\|AND\|CALL\|CBW\|CLC\|CLD\|CLI\|CMC\|CMP\|CMPSB\|CMPSW\|CWD\|DAA\|DAS\|DEC\|DIV\|FWAIT\|HLT\|IDIV\|IN\|INC\|INT\|INTO\|IRET\|J\|JCXZ\|JMP\|JE\|JL\|JG\|JNE\|LAHF\|LDS\|LEA\|LES\|LOCK\|LODSB\|LODSW\|LOOP\|LOOPE\|LOOPNE\|LOOPNZ\|LOOPZ\|MOV\|MOVSB\|MOVSW\|MUL\|NEG\|NOP\|NOT\|OR\|OUT\|POP\|POPF\|PUSH\|PUSHF\|RCL\|RCR\|REP\|REPE\|REPNE\|REPNZ\|REPZ\|RET\|ROL\|ROR\|SAHF\|SAL\|SAR\|SBB\|SCASB\|SCASW\|SHL\|SHR\|STC\|STD\|STI\|STOSB\|STOSW\|SUB\|TEST\|WAIT\|XCHG\|XLAT\|XOR\)\b" color="keyword">
 <item name="8087set" words="\b\(f2xm1\|fabs\|fadd\|faddp\|fbld\|fbstp\|fchs\|fclex\|fcom\|fcomp\|fdecstp\|fdisi\|fdiv\|fdivp\|fdivr\|fdivrp\|feni\|ffree\|fiadd\|ficom\|ficomp\|fidiv\|fidivr\|fild\|fimul\|fincstp\|finit\|fist\|fistp\|fisub\|fisubr\|fld\|fld1\|fldcw\|fldenv\|fldl2e\|fldl2t\|fldlg2\|fldln2\|fldpi\|fldz\|fmul\|fmulp\|fnclex\|fndisi\|fneni\|fninit\|fnop\|fnsave\|fnstcw\|fnstenv\|fnstsw\|fpatan\|fprem\|fptan\|frndint\|frstor\|fsave\|fscale\|fsqrt\|fst\|fstcw\|fstenv\|fstp\|fstsw\|fsub\|fsubp\|fsubr\|fsubrp\|ftst\|fucompp\|fxam\|fxch\|fxtract\|fyl2x\|fyl2xp1\)\b" color="keyword">
 <item name="8087SET" words="\B\(F2XM1\|FABS\|FADD\|FADDP\|FBLD\|FBSTP\|FCHS\|FCLEX\|FCOM\|FCOMP\|FDECSTP\|FDISI\|FDIV\|FDIVP\|FDIVR\|FDIVRP\|FENI\|FFREE\|FIADD\|FICOM\|FICOMP\|FIDIV\|FIDIVR\|FILD\|FIMUL\|FINCSTP\|FINIT\|FIST\|FISTP\|FISUB\|FISUBR\|FLD\|FLD1\|FLDCW\|FLDENV\|FLDL2E\|FLDL2T\|FLDLG2\|FLDLN2\|FLDPI\|FLDZ\|FMUL\|FMULP\|FNCLEX\|FNDISI\|FNENI\|FNINIT\|FNOP\|FNSAVE\|FNSTCW\|FNSTENV\|FNSTSW\|FPATAN\|FPREM\|FPTAN\|FRNDINT\|FRSTOR\|FSAVE\|FSCALE\|FSQRT\|FST\|FSTCW\|FSTENV\|FSTP\|FSTSW\|FSUB\|FSUBP\|FSUBR\|FSUBRP\|FTST\|FUCOMPP\|FXAM\|FXCH\|FXTRACT\|FYL2X\|FYL2XP1\)\b" color="keyword">
 <item name="mmxset" words="\b\(emms\|movd\|movq\|packssdw\|packsswb\|packuswb\|paddb\|paddd\|paddsb\|paddsw\|paddusb\|paddusw\|paddw\|pand\|pandn\|pcmpeqb\|pcmpeqd\|pcmpeqw\|pcmpgtb\|pcmpgtd\|pcmpgtw\|pmaddwd\|pmulhw\|pmullw\|por\|pshimd\|pshimq\|pshimw\|pslld\|psllq\|psllw\|psrad\|psraw\|psrld\|psrlq\|psrlw\|psubb\|psubd\|psubsb\|psubsw\|psubusb\|psubusw\|psubw\|punpckhbw\|punpckhdq\|punpckhwd\|punpcklbw\|punpckldq\|punpcklwd\|pxor\)\b" color="keyword">
 <item name="MMXSET" words="\B\(EMMS\|MOVD\|MOVQ\|PACKSSDW\|PACKSSWB\|PACKUSWB\|PADDB\|PADDD\|PADDSB\|PADDSW\|PADDUSB\|PADDUSW\|PADDW\|PAND\|PANDN\|PCMPEQB\|PCMPEQD\|PCMPEQW\|PCMPGTB\|PCMPGTD\|PCMPGTW\|PMADDWD\|PMULHW\|PMULLW\|POR\|PSHIMD\|PSHIMQ\|PSHIMW\|PSLLD\|PSLLQ\|PSLLW\|PSRAD\|PSRAW\|PSRLD\|PSRLQ\|PSRLW\|PSUBB\|PSUBD\|PSUBSB\|PSUBSW\|PSUBUSB\|PSUBUSW\|PSUBW\|PUNPCKHBW\|PUNPCKHDQ\|PUNPCKHWD\|PUNPCKLBW\|PUNPCKLDQ\|PUNPCKLWD\|PXOR\)\b" color="keyword">
 <item name="pentset" words="\b\(cmpxchg8b\|cpuid\|rdmsr\|rdtsc\|rsm\|wrmsr\)\b" color="keyword">
 <item name="PENTSET" words="\B\(CMPXCHG8B\|CPUID\|RDMSR\|RDTSC\|RSM\|WRMSR\)\b" color="keyword">
 <item name="proset" words="\b\(cmov\|fcmov\|fcomi\|fcomip\|fucomi\|fucomip\|rdpmc\|salc\)\b" color="keyword">
 <item name="PROSET" words="\B\(CMOV\|FCMOV\|FCOMI\|FCOMIP\|FUCOMI\|FUCOMIP\|RDPMC\|SALC\)\b" color="keyword">
 <item name="conditions" words="\b\(a\|ae\|b\|be\|c\|cxz\|e\|g\|ge\|l\|le\|mp\|na\|nae\|nb\|nbe\|nc\|ne\|ng\|nge\|nl\|nle\|no\|np\|ns\|nz\|o\|p\|pe\|po\|s\|z\)\b" color="keyword">
 <item name="CONDITIONS" words="\b\(A\|AE\|B\|BE\|C\|CXZ\|E\|G\|GE\|L\|LE\|MP\|NA\|NAE\|NB\|NBE\|NC\|NE\|NG\|NGE\|NL\|NLE\|NO\|NP\|NS\|NZ\|O\|P\|PE\|PO\|S\|Z\)\b" color="keyword">
 <item name="reg8086" words="\b\(ah\|al\|ax\|bh\|bl\|bp\|bx\|ch\|cl\|cs\|cx\|dh\|di\|dl\|ds\|dx\|es\|ip\|si\|sp\|ss\)\b" color="variable">
 <item name="REG8086" words="\b\(AH\|AL\|AX\|BH\|BL\|BP\|BX\|CH\|CL\|CS\|CX\|DH\|DI\|DL\|DS\|DX\|ES\|IP\|SI\|SP\|SS\)\b" color="variable">
 <item name="reg80386" words="\b\(cr0|\cr2\|cr3\|dr0\|dr1\|dr2\|dr3\|dr6\|dr7\|eax\|ebp\|ebx\|ecx\|edi\|edx\|esi\|esp\|fs\|gs\|tr4\|tr5\|tr6\|tr7\)\b" color="variable">
 <item name="REG80386" words="\b\(CR0|\CR2\|CR3\|DR0\|DR1\|DR2\|DR3\|DR6\|DR7\|EAX\|EBP\|EBX\|ECX\|EDI\|EDX\|ESI\|ESP\|FS\|GS\|TR4\|TR5\|TR6\|TR7\)\b" color="variable">
 <item name="labels" words="^[a-zA-Z_][a-zA-Z0-9_]*\:" color="function">
 <item name="operators" words="\(+\|-\|\*\|/\|=\|(\|)\)" color="operator">
 <item name="hex1" words="\$[a-fA-F0-9]+" color="hexidecimal">
 <item name="hex2" words="[a-fA-F0-9][a-fA-F0-9]+\(h\|H\)" color="hexidecimal">
 <item name="numbers" words="\b[0-9]+\b" color="decimal">
 <item name="binary" words="%[0-1]+\b" color="octal">
 <item name="macros" words="\b[A-Z_][A-Z0-9_\-]+\b" color="macro">
</pattern>

<python>
import glimmer
import string

def x86_enter_callback():
   insert = "\n"
   extralen = 0
   slen = 0
   file = glimmer.get_file_number()
   tstart = glimmer.line_start()
   tend = glimmer.current_position()
   if (tend-tstart) > 0:
      chars = glimmer.get_text(tstart, tend)
      slen = len(chars)
      if slen > 0:
         index = 0
         while index < slen:
            c = chars[index]
            if c == '\t' or c == ' ':
               insert = insert + chars[index]
               index = index+1
            else:
               break
         c = chars[slen-1]
         if c == ':':
            extralen = glimmer.get_file_tab_width(file)
            if glimmer.get_file_use_spaces(file):
               while extralen > 0:
                  insert = insert + " "
                  extralen = extralen-1
            else:
               insert = insert + '\t'
   glimmer.insert(insert)

glimmer.register_signal_hook("enter-pressed", x86_enter_callback)

def x86_tab_callback():
   tablen = 0
   insertchars = ""
   file = glimmer.get_file_number()
   if glimmer.get_file_use_spaces(file):
      tablen = glimmer.get_file_tab_width(file)
      pos = glimmer.current_position()
      lstart = glimmer.line_start()
      if pos - lstart > 0:
         str1 = glimmer.get_text(lstart, pos)
      else:
         str1 = ""
      if glimmer.get_tab_stops():
         str1 = string.expandtabs(str1, tablen)
         len1 = len(str1)
         del str1
         tablen = tablen - (len1 % tablen)
      while tablen > 0:
         insertchars = insertchars + " "
         tablen = tablen-1
   else:
      insertchars = insertchars + "\t"
   glimmer.insert(insertchars)

glimmer.register_signal_hook("tab-pressed", x86_tab_callback)

def insert_x86_comment():
    glimmer.freeze()
    if glimmer.has_selection():
        start = glimmer.selection_start()
        end = glimmer.selection_end()
        file = glimmer.get_file_number()
        glimmer.move(0)
        line1 = glimmer.line_by_pos(start)
        line2 = glimmer.line_by_pos(end)
        cur = line1
        print start
        print end
        while cur <= line2:
           glimmer.move_to_col(0)
           glimmer.move_to_line(cur)
           glimmer.insert(";")
           cur = cur+1
        glimmer.move_to(end+((line2-line1)+1)*2)
    else:
        glimmer.insert(";")
    glimmer.thaw()

glimmer.add_item_to_popup_menu("Comment (;)", -1, insert_x86_comment)
</python>
