<glimmer-definition>
   <settings>
      <language>x86 Assembly Language</language>
      <compiler>nasm</compiler>
      <debugger>gdb %1</debugger>
      <execution> </execution>
      <auto-indent>1</auto-indent>
      <use-spaces>0</use-spaces>
      <tab-stop>4</tab-stop>
   </settings>

   <mime-types>
      <extension>x86</extension>
      <extension>asm</extension>
   </mime-types>

   <syntax-items>
      <syntax-item>
         <name>string1</name>
         <start-regex>&quot;</start-regex>
         <end-regex>&quot;</end-regex>
         <style>string</style>
      </syntax-item>
      <syntax-item>
         <name>string2</name>
         <start-regex>&apos;</start-regex>
         <end-regex>&apos;</end-regex>
         <style>string</style>
      </syntax-item>
      <syntax-item>
         <name>comment</name>
         <start-regex>;</start-regex>
         <end-regex>\n</end-regex>
         <style>comment</style>
      </syntax-item>
   </syntax-items>

   <pattern-items>
      <pattern-item>
         <name>defs</name>
         <regex>^#\ *\t*\(include\|if\|ifdef\|ifndef\|else\|elif\|define\|endif\|pragma\)\b</regex>
         <style>preprocessor</style>
      </pattern-item>
      <pattern-item>
         <name>dbequ</name>
         <regex>\b\(db\|dw\|dd\|equ\)\b</regex>
         <style>keyword</style>
      </pattern-item>
      <pattern-item>
         <name>80186set</name>
         <regex>\b\(bound\|enter\|imul\|insb\|insw\|leave\|outsb\|outsw\|popa\|pusha\)\b</regex>
         <style>keyword</style>
      </pattern-item>
      <pattern-item>
         <name>80186SET</name>
         <regex>\B\(BOUND\|ENTER\|IMUL\|INSB\|INSW\|LEAVE\|OUTSB\|OUTSW\|POPA\|PUSHA\)\b</regex>
         <style>keyword</style>
      </pattern-item>
      <pattern-item>
         <name>80286set</name>
         <regex>\b\(arpl\|clts\|lar\|lgdt\|lidt\|lldt\|lmsw\|lsl\|ltr\|pushw\|sgdt\|sidt\|sldt\|smsw\|str\|verr\|verw\)\b</regex>
         <style>keyword</style>
      </pattern-item>
      <pattern-item>
         <name>80286SET</name>
         <regex>\B\(ARPL\|CLTS\|LAR\|LGDT\|LIDT\|LLDT\|LMSW\|LSL\|LTR\|PUSHW\|SGDT\|SIDT\|SLDT\|SMSW\|STR\|VERR\|VERW\)\b</regex>
         <style>keyword</style>
      </pattern-item>
      <pattern-item>
         <name>80287set</name>
         <regex>\b\(fsetpm\)\b</regex>
         <style>keyword</style>
      </pattern-item>
      <pattern-item>
         <name>80287SET</name>
         <regex>\B\(FSETPM\)\b</regex>
         <style>keyword</style>
      </pattern-item>
      <pattern-item>
         <name>80386set</name>
         <regex>\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</regex>
         <style>keyword</style>
      </pattern-item>
      <pattern-item>
         <name>80386SET</name>
         <regex>\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</regex>
         <style>keyword</style>
      </pattern-item>
      <pattern-item>
         <name>80387set</name>
         <regex>\b\(fcos\|fprem1\|fsin\|fsincos\|fucom\|fucomp\|fucompp\)\b</regex>
         <style>keyword</style>
      </pattern-item>
      <pattern-item>
         <name>80387SET</name>
         <regex>\B\(FCOS\|FPREM1\|FSIN\|FSINCOS\|FUCOM\|FUCOMP\|FUCOMPP\)\b</regex>
         <style>keyword</style>
      </pattern-item>
      <pattern-item>
         <name>80486set</name>
         <regex>\b\(bswap\|cmpxchg\|invd\|invlpg\|wbinvd\|xadd\)\b</regex>
         <style>keyword</style>
      </pattern-item>
      <pattern-item>
         <name>80486SET</name>
         <regex>\B\(BSWAP\|CMPXCHG\|INVD\|INVLPG\|WBINVD\|XADD\)\b</regex>
         <style>keyword</style>
      </pattern-item>
      <pattern-item>
         <name>8086set</name>
         <regex>\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</regex>
         <style>keyword</style>
      </pattern-item>
      <pattern-item>
         <name>8086SET</name>
         <regex>\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</regex>
         <style>keyword</style>
      </pattern-item>
      <pattern-item>
         <name>8087set</name>
         <regex>\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</regex>
         <style>keyword</style>
      </pattern-item>
      <pattern-item>
         <name>8087SET</name>
         <regex>\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</regex>
         <style>keyword</style>
      </pattern-item>
      <pattern-item>
         <name>mmxset</name>
         <regex>\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</regex>
         <style>keyword</style>
      </pattern-item>
      <pattern-item>
         <name>MMXSET</name>
         <regex>\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</regex>
         <style>keyword</style>
      </pattern-item>
      <pattern-item>
         <name>pentset</name>
         <regex>\b\(cmpxchg8b\|cpuid\|rdmsr\|rdtsc\|rsm\|wrmsr\)\b</regex>
         <style>keyword</style>
      </pattern-item>
      <pattern-item>
         <name>PENTSET</name>
         <regex>\B\(CMPXCHG8B\|CPUID\|RDMSR\|RDTSC\|RSM\|WRMSR\)\b</regex>
         <style>keyword</style>
      </pattern-item>
      <pattern-item>
         <name>proset</name>
         <regex>\b\(cmov\|fcmov\|fcomi\|fcomip\|fucomi\|fucomip\|rdpmc\|salc\)\b</regex>
         <style>keyword</style>
      </pattern-item>
      <pattern-item>
         <name>PROSET</name>
         <regex>\B\(CMOV\|FCMOV\|FCOMI\|FCOMIP\|FUCOMI\|FUCOMIP\|RDPMC\|SALC\)\b</regex>
         <style>keyword</style>
      </pattern-item>
      <pattern-item>
         <name>conditions</name>
         <regex>\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</regex>
         <style>keyword</style>
      </pattern-item>
      <pattern-item>
         <name>CONDITIONS</name>
         <regex>\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</regex>
         <style>keyword</style>
      </pattern-item>
      <pattern-item>
         <name>reg8086</name>
         <regex>\b\(ah\|al\|ax\|bh\|bl\|bp\|bx\|ch\|cl\|cs\|cx\|dh\|di\|dl\|ds\|dx\|es\|ip\|si\|sp\|ss\)\b</regex>
         <style>variable</style>
      </pattern-item>
      <pattern-item>
         <name>REG8086</name>
         <regex>\b\(AH\|AL\|AX\|BH\|BL\|BP\|BX\|CH\|CL\|CS\|CX\|DH\|DI\|DL\|DS\|DX\|ES\|IP\|SI\|SP\|SS\)\b</regex>
         <style>variable</style>
      </pattern-item>
      <pattern-item>
         <name>reg80386</name>
         <regex>\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</regex>
         <style>variable</style>
      </pattern-item>
      <pattern-item>
         <name>REG80386</name>
         <regex>\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</regex>
         <style>variable</style>
      </pattern-item>
      <pattern-item>
         <name>labels</name>
         <regex>^[a-zA-Z_][a-zA-Z0-9_]*\:</regex>
         <style>function</style>
      </pattern-item>
      <pattern-item>
         <name>operators</name>
         <regex>\(+\|-\|\*\|/\|=\|(\|)\|\$\)</regex>
         <style>operator</style>
      </pattern-item>
      <pattern-item>
         <name>hex1</name>
         <regex>\$[a-fA-F0-9]+</regex>
         <style>hexidecimal</style>
      </pattern-item>
      <pattern-item>
         <name>hex2</name>
         <regex>[a-fA-F0-9][a-fA-F0-9]+\(h\|H\)</regex>
         <style>hexidecimal</style>
      </pattern-item>
      <pattern-item>
         <name>hex3</name>
         <regex>0x[a-fA-F0-9]+</regex>
         <style>hexidecimal</style>
      </pattern-item>
      <pattern-item>
         <name>numbers</name>
         <regex>\b[0-9]+\b</regex>
         <style>decimal</style>
      </pattern-item>
      <pattern-item>
         <name>binary</name>
         <regex>\(%[0-1]+\b\|[0-1][0-1][0-1][0-1][0-1][0-1][0-1][0-1]b\)</regex>
         <style>decimal</style>
      </pattern-item>
      <pattern-item>
         <name>macros</name>
         <regex>\b[A-Z_][A-Z0-9_\-]+\b</regex>
         <style>macro</style>
      </pattern-item>
   </pattern-items>
</glimmer-definition>

<python-definition>
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-definition>
