<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE language SYSTEM "language.dtd">
<!-- kate: space-indent on; indent-width 2; -->

<!-- Microchip PIC assembler syntaxfile for gpasm/mpasm assembler by
  * Original author: Alain GIBAUD (alain.gibaud@univ-valenciennes.fr)
  * Small modifications for the new DTD: Joseph Wenninger <jowenn@kde.org>
  * Updated for 16-bit devices, etc.: Laurence Withers <lwithers@users.sf.net>
-->

<language name="PicAsm" version="4" kateversion="2.3" section="Assembler" extensions="*.src;*.SRC;*.asm;*.ASM;*.pic;*.PIC" mimetype="text/x-PicSrc;text/x-PicHdr" author="Alain GIBAUD (alain.gibaud@univ-valenciennes.fr)" license="LGPL">
  
  <highlighting>
    <list name="directives">
      <item>__BADRAM</item>
      <item>__CONFIG</item>
      <item>__IDLOCS</item>
      <item>__MAXRAM</item>
      
      <item>cblock</item>
      <item>constant</item>
      <item>da</item>
      <item>data</item>
      <item>db</item>
      <item>de</item>
      <item>dt</item>
      <item>dw</item>
      <item>endc</item>
      <item>endm</item>
      <item>equ</item>
      <item>error</item>
      <item>errorlevel</item>
      <item>exitm</item>
      <item>fill</item>
      <item>list</item>
      <item>local</item>
      <item>macro</item>
      <item>messg</item>
      <item>noexpand</item>
      <item>nolist</item>
      <item>org</item>
      <item>page</item>
      <item>processor</item>
      <item>radix</item>
      <item>res</item>
      <item>set</item>
      <item>space</item>
      <item>subtitle</item>
      <item>title</item>
      <item>variable</item>
      <item>end</item>
      
      <item>CBLOCK</item>
      <item>CONSTANT</item>
      <item>DA</item>
      <item>DATA</item>
      <item>DB</item>
      <item>DE</item>
      <item>DT</item>
      <item>DW</item>
      <item>ENDC</item>
      <item>ENDM</item>
      <item>EQU</item>
      <item>ERROR</item>
      <item>ERRORLEVEL</item>
      <item>EXITM</item>
      <item>FILL</item>
      <item>LIST</item>
      <item>LOCAL</item>
      <item>MACRO</item>
      <item>MESSG</item>
      <item>NOEXPAND</item>
      <item>NOLIST</item>
      <item>ORG</item>
      <item>PAGE</item>
      <item>PROCESSOR</item>
      <item>RADIX</item>
      <item>RES</item>
      <item>SET</item>
      <item>SPACE</item>
      <item>SUBTITLE</item>
      <item>TITLE</item>
      <item>VARIABLE</item>
      <item>END</item>
    </list>
    
    <list name="conditional">
      <item>if</item>
      <item>else</item>
      <item>idef</item>
      <item>ifndef</item>
      <item>endif</item>
      <item>while</item>
      <item>include</item>
      <item>endw</item>
      <item>{</item>
      <item>}</item>
    </list>
    
    <list name="gpasm_macro">
      <item>addcf</item>
      <item>b</item>
      <item>clrc</item>
      <item>clrz</item>
      <item>setc</item>
      <item>setz</item>
      <item>movfw</item>
      <item>skpc</item>
      <item>skpz</item>
      <item>skpnc</item>
      <item>skpnz</item>
      <item>subcf</item>
      <item>tstf</item>
      
      <item>ADDCF</item>
      <item>B</item>
      <item>CLRC</item>
      <item>CLRZ</item>
      <item>SETC</item>
      <item>SETZ</item>
      <item>MOVFW</item>
      <item>SKPC</item>
      <item>SKPZ</item>
      <item>SKPNC</item>
      <item>SKPNZ</item>
      <item>SUBCF</item>
      <item>TSTF</item>
    </list>
    
    <list name="instructions">
      <item>addlw</item>
      <item>addwf</item>
      <item>addwfc</item>
      <item>andlw</item>
      <item>andwf</item>
      <item>bc</item>
      <item>bcf</item>
      <item>bn</item>
      <item>bnc</item>
      <item>bnov</item>
      <item>bnz</item>
      <item>bov</item>
      <item>bra</item>
      <item>bsf</item>
      <item>btg</item>
      <item>bz</item>
      <item>btfsc</item>
      <item>btfss</item>
      <item>call</item>
      <item>clrf</item>
      <item>clrw</item>
      <item>clrwdt</item>
      <item>comf</item>
      <item>cpfseq</item>
      <item>cpfslt</item>
      <item>cpfsgt</item>
      <item>daw</item>
      <item>decf</item>
      <item>dcfsnz</item>
      <item>decfsz</item>
      <item>goto</item>
      <item>incf</item>
      <item>incfsz</item>
      <item>infsnz</item>
      <item>iorlw</item>
      <item>iorwf</item>
      <item>lfsr</item>
      <item>movf</item>
      <item>movff</item>
      <item>movlb</item>
      <item>movlw</item>
      <item>movwf</item>
      <item>mullw</item>
      <item>mulwf</item>
      <item>negf</item>
      <item>nop</item>
      <item>option</item>
      <item>pop</item>
      <item>push</item>
      <item>rcall</item>
      <item>reset</item>
      <item>retfie</item>
      <item>retlw</item>
      <item>return</item>
      <item>rlcf</item>
      <item>rlf</item>
      <item>rlncf</item>
      <item>rrcf</item>
      <item>rrf</item>
      <item>rrncf</item>
      <item>setf</item>
      <item>sleep</item>
      <item>subfwb</item>
      <item>sublw</item>
      <item>subwf</item>
      <item>subwfb</item>
      <item>swapf</item>
      <item>tblrd</item>
      <item>tblwt</item>
      <item>tstfsz</item>
      <item>xorlw</item>
      <item>xorwf</item>
      
      <item>ADDLW</item>
      <item>ADDWF</item>
      <item>ADDWFC</item>
      <item>ANDLW</item>
      <item>ANDWF</item>
      <item>BC</item>
      <item>BCF</item>
      <item>BN</item>
      <item>BNC</item>
      <item>BNOV</item>
      <item>BNZ</item>
      <item>BOV</item>
      <item>BRA</item>
      <item>BSF</item>
      <item>BTG</item>
      <item>BZ</item>
      <item>BTFSC</item>
      <item>BTFSS</item>
      <item>CALL</item>
      <item>CLRF</item>
      <item>CLRW</item>
      <item>CLRWDT</item>
      <item>COMF</item>
      <item>CPFSEQ</item>
      <item>CPFSLT</item>
      <item>CPFSGT</item>
      <item>DAW</item>
      <item>DCFSNZ</item>
      <item>DECF</item>
      <item>DECFSZ</item>
      <item>GOTO</item>
      <item>INCF</item>
      <item>INCFSZ</item>
      <item>INFSNZ</item>
      <item>IORLW</item>
      <item>IORWF</item>
      <item>LFSR</item>
      <item>MOVF</item>
      <item>MOVFF</item>
      <item>MOVLB</item>
      <item>MOVLW</item>
      <item>MOVWF</item>
      <item>MULLW</item>
      <item>MULWF</item>
      <item>NEGF</item>
      <item>NOP</item>
      <item>OPTION</item>
      <item>POP</item>
      <item>PUSH</item>
      <item>RCALL</item>
      <item>RESET</item>
      <item>RETFIE</item>
      <item>RETLW</item>
      <item>RETURN</item>
      <item>RLCF</item>
      <item>RLF</item>
      <item>RLNCF</item>
      <item>RRCF</item>
      <item>RRF</item>
      <item>RRNCF</item>
      <item>SETF</item>
      <item>SLEEP</item>
      <item>SUBFWB</item>
      <item>SUBLW</item>
      <item>SUBWF</item>
      <item>SUBWFB</item>
      <item>SWAPF</item>
      <item>TBLRD</item>
      <item>TBLWT</item>
      <item>TSTFSZ</item>
      <item>XORLW</item>
      <item>XORWF</item>
    </list>
    
    <list name="instruction_attr">
      <item>A</item>
      <item>ACCESS</item>
      <item>BANKED</item>
      <item>W</item>
      <item>F</item>
    </list>
    
    <contexts>
      
      <!-- The main ('normal') context -->
      
      <context name="normal" attribute="Normal Text" lineEndContext="#stay">
        <keyword attribute="Directives" context="#stay" String="directives"/>
        <keyword attribute="Instructions" context="#stay" String="instructions"/>
        <keyword attribute="InstructionAttr" context="#stay" String="instruction_attr"/>
        <keyword attribute="Preprocessor" context="#stay" String="conditional"/>
        <keyword attribute="GPASM-macros" context="#stay" String="gpasm_macro"/>
        <HlCHex attribute="Based Numbers" context="#stay"/>
        <RegExpr attribute="Based Numbers" context="#stay" String="([ \t,][0-9A-F]+H[ \t,])" insensitive="true" />
        <RegExpr attribute="Based Numbers" context="#stay" String="([ \t,][0-9A-F]+H)$" insensitive="true" />
        <RegExpr attribute="Based Numbers" context="#stay" String="([ \t,][0-9]+D)" insensitive="true" />
        <RegExpr attribute="Based Numbers" context="#stay" String="([ \t,][0-7]+O)" insensitive="true" />
        <RegExpr attribute="Based Numbers" context="#stay" String="([ \t,][0-1]+B)" insensitive="true" />
        <Int attribute="Unbased Numbers" context="#stay" />
        <HlCChar attribute="Char" context="#stay"/>
        <Detect2Chars attribute="Char" context="ASCIIChar" char="A" char1="'" />
        <Detect2Chars attribute="Char" context="ASCIIChar" char="a" char1="'" />
        <Detect2Chars attribute="Based Numbers" context="binaryDigits"  char="B" char1="'" />
        <Detect2Chars attribute="Based Numbers" context="binaryDigits"  char="b" char1="'" />
        <Detect2Chars attribute="Based Numbers" context="hexDigits"  char="H" char1="'" />
        <Detect2Chars attribute="Based Numbers" context="hexDigits"  char="h" char1="'" />
        <Detect2Chars attribute="Based Numbers" context="octDigits"  char="O" char1="'" />
        <Detect2Chars attribute="Based Numbers" context="octDigits"  char="o" char1="'" />
        <Detect2Chars attribute="Based Numbers" context="decimalDigits"  char="D" char1="'" />
        <Detect2Chars attribute="Based Numbers" context="decimalDigits"  char="d" char1="'" />
        <DetectChar attribute="String" context="string" char="&quot;" />
        <DetectChar attribute="Comment" context="comment" char=";" />
        <AnyChar attribute="Symbol" context="#stay" String="-/*%+=&gt;&lt;&amp;|^!~" />
        <StringDetect attribute="Preprocessor" context="#stay" String="#define" />
        <StringDetect attribute="Preprocessor" context="#stay" String="#undefine" />
        <StringDetect attribute="Preprocessor" context="#stay" String="#v" />
      </context>
      
      
      
      <!-- Additional contexts -->
      
      <context name="string" attribute="String" lineEndContext="#pop">
        <LineContinue attribute="String" context="#stay"/>
        <HlCStringChar attribute="Char" context="#stay"/>
        <DetectChar attribute="String" context="#pop" char="&quot;"/>
      </context>
      
      <context name="comment" attribute="Comment" lineEndContext="#pop">
        <RegExpr attribute="Instructions" context="#stay"
                  String="(INPUT|OUTPUT|PARAMETERS|AUTHOR|EMAIL)" />
        <RegExpr attribute="Alert" context="#stay" String="(FIXME|TODO)" />
      </context>
      
      
      
      <!-- Quoted numbers -->
      
      <context name="decimalDigits" attribute="Based Numbers" lineEndContext="#pop">
        <DetectChar attribute="Based Numbers" context="#pop" char="'"/>
        <RegExpr attribute="Error" context="QuotedNumError" String="\D" />
      </context>
      
      <context name="binaryDigits" attribute="Based Numbers" lineEndContext="#pop">
        <DetectChar attribute="Based Numbers" context="#pop" char="'"/>
        <RegExpr attribute="Error" context="QuotedNumError" String="[^0-1]" />
      </context>
      
      <context name="hexDigits" attribute="Based Numbers" lineEndContext="#pop">
        <DetectChar attribute="Based Numbers" context="#pop" char="'"/>
        <RegExpr attribute="Error" context="QuotedNumError" String="[^0-9A-Fa-f]" />
      </context>
      
      <context name="octDigits" attribute="Based Numbers" lineEndContext="#pop">
        <DetectChar attribute="Based Numbers" context="#pop" char="'"/>
        <RegExpr attribute="Error" context="QuotedNumError" String="[^0-7]" />
      </context>
      
      <context name="ASCIIChar" attribute="Char" lineEndContext="#pop">
        <DetectChar attribute="Char" context="#pop" char="'"/>
        <RegExpr attribute="Error" context="QuotedNumError" String=".[^']" />
      </context>
      
      <context name="QuotedNumError" attribute="Error" lineEndContext="#pop#pop">
        <DetectChar attribute="Error" context="#pop#pop" char="'" />
      </context>
      
    </contexts>
    
    
    <itemDatas>
      <itemData name="Normal Text"      defStyleNum="dsNormal"/>
      <itemData name="Directives"       defStyleNum="dsOthers"/>
      <itemData name="Preprocessor"     defStyleNum="dsOthers"/>
      <itemData name="Instructions"     defStyleNum="dsKeyword"/>
      <itemData name="InstructionAttr"  defStyleNum="dsNormal" color="#000080" selColor="#000080" bold="0" italic="1"/>
      <itemData name="Unbased Numbers"  defStyleNum="dsDecVal"/>
      <itemData name="Char"             defStyleNum="dsChar"/>
      <itemData name="String"           defStyleNum="dsString"/>
      <itemData name="Comment"          defStyleNum="dsComment" />
      <itemData name="Symbol"           defStyleNum="dsNormal" color="#FF0000" selColor="#083194" bold="0" italic="0"/>
      <itemData name="Based Numbers"    defStyleNum="dsBaseN" />
      <itemData name="GPASM-macros"     defStyleNum="dsNormal" color="#000000" selColor="#000000" bold="1" italic="1"/>
      <itemData name="Alert"            defStyleNum="dsAlert" />
      <itemData name="Error"            defStyleNum="dsError" />
    </itemDatas>
    
  </highlighting>
  
  
  <general>
    <comments>
      <comment name="singleLine" start=";" />
    </comments>
    <keywords casesensitive="1" />
  </general>
  
</language>
