It is currently Wed Nov 22, 2017 8:02 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Sat Oct 21, 2017 9:06 am 
Offline
User avatar

Joined: Mon Oct 20, 2014 1:50 pm
Posts: 94
This week I decided to pick up the Nerdy Nights tutorial and learn some 6502. I wanted a UDL (user-defined language) for syntax highlighting but I couldn't find one. Everything was either a broken link or too old for the current NP++ so I decided to make my own! It's based off the default assembly highlighting and supports all of the ASM6 directives. Here's a preview:

Image

Installation:
  • Copy the code below and save it as an XML file.
  • In Notepad++, go to Language -> Define Your Language... -> Import.
  • Import the XML file and it will appear in the Language menu.

Note:
The UDL system of Notepad++ is not perfect so I had to do some hacks to get this to work. If you type an array of values, the commas are highlighted along with the numbers. There's nothing I can do to fix this. And if a number is touching the EOF, it will not highlight correctly. Lastly, you need to use the ASM6 file extension so that you don't get any conflicts with the default Assembly highlighting. Other than that, this should work well and be easily adapted for other assemblers by changing the directives in the 3rd keyword list. If you do this, feel free to share below!

Finally, here's the code:
Code:
<NotepadPlus>
    <UserLang name="ASM6" ext="asm6" udlVersion="2.1">
        <Settings>
            <Global caseIgnored="yes" allowFoldOfComments="yes" foldCompact="no" forcePureLC="0" decimalSeparator="0" />
            <Prefix Keywords1="no" Keywords2="no" Keywords3="no" Keywords4="no" Keywords5="no" Keywords6="no" Keywords7="no" Keywords8="no" />
        </Settings>
        <KeywordLists>
            <Keywords name="Comments">00; 01 02 03 04</Keywords>
            <Keywords name="Numbers, prefix1"></Keywords>
            <Keywords name="Numbers, prefix2"># $ % 0 1 2 3 4 5 6 7 8 9 A B C D E F a b c d e f</Keywords>
            <Keywords name="Numbers, extras1"># $ % A B C D E F a b c d e f</Keywords>
            <Keywords name="Numbers, extras2"></Keywords>
            <Keywords name="Numbers, suffix1"></Keywords>
            <Keywords name="Numbers, suffix2">,</Keywords>
            <Keywords name="Numbers, range"></Keywords>
            <Keywords name="Operators1">( ) + - ~ ! &lt; &gt; * / % = ! &amp; ^ |</Keywords>
            <Keywords name="Operators2"></Keywords>
            <Keywords name="Folders in code1, open"></Keywords>
            <Keywords name="Folders in code1, middle"></Keywords>
            <Keywords name="Folders in code1, close"></Keywords>
            <Keywords name="Folders in code2, open"></Keywords>
            <Keywords name="Folders in code2, middle"></Keywords>
            <Keywords name="Folders in code2, close"></Keywords>
            <Keywords name="Folders in comment, open"></Keywords>
            <Keywords name="Folders in comment, middle"></Keywords>
            <Keywords name="Folders in comment, close"></Keywords>
            <Keywords name="Keywords1">adc and asl bcc bcs beq bit bmi bne bpl brk bvc bvs clc cld cli clv cmp cpx cpy dec dex dey eor inc inx iny jmp jsr lda ldx ldy lsr nop ora pha php pla plp rol ror rti rts sbc sec sed sei sta stx sty tax tay tsx txa txs tya</Keywords>
            <Keywords name="Keywords2">a x y</Keywords>
            <Keywords name="Keywords3">align base bin byte db dc.b dc.w dcb dcw dh dl ds.b ds.w dsb dsw dw else elseif ende endif endm endr enum equ error fillvalue hex if ifdef ifndef incbin include incsrc macro org pad rept word .align .base .bin .byte .db .dc.b .dc.w .dcb .dcw .dh .dl .ds.b .ds.w .dsb .dsw .dw .else .elseif .ende .endif .endm .endr .enum .equ .error .fillvalue .hex .if .ifdef .ifndef .incbin .include .incsrc .macro .org .pad .rept .word</Keywords>
            <Keywords name="Keywords4"></Keywords>
            <Keywords name="Keywords5"></Keywords>
            <Keywords name="Keywords6"></Keywords>
            <Keywords name="Keywords7"></Keywords>
            <Keywords name="Keywords8"></Keywords>
            <Keywords name="Delimiters">00&apos; 01 02&apos; 03&quot; 04 05&quot; 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23</Keywords>
        </KeywordLists>
        <Styles>
            <WordsStyle name="DEFAULT" fgColor="FFFFFF" bgColor="000000" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="COMMENTS" fgColor="00D200" bgColor="000000" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="LINE COMMENTS" fgColor="00FF00" bgColor="000000" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="NUMBERS" fgColor="FF8000" bgColor="000000" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="KEYWORDS1" fgColor="FFCC00" bgColor="000000" fontName="" fontStyle="1" nesting="0" />
            <WordsStyle name="KEYWORDS2" fgColor="8080FF" bgColor="000000" fontName="" fontStyle="1" nesting="0" />
            <WordsStyle name="KEYWORDS3" fgColor="8080FF" bgColor="000000" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="KEYWORDS4" fgColor="FFFFFF" bgColor="000000" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="KEYWORDS5" fgColor="FFFFFF" bgColor="000000" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="KEYWORDS6" fgColor="FFFFFF" bgColor="000000" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="KEYWORDS7" fgColor="FFFFFF" bgColor="000000" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="KEYWORDS8" fgColor="FFFFFF" bgColor="000000" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="OPERATORS" fgColor="FFCC00" bgColor="000000" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="FOLDER IN CODE1" fgColor="FFFFFF" bgColor="000000" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="FOLDER IN CODE2" fgColor="FFFFFF" bgColor="000000" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="FOLDER IN COMMENT" fgColor="FFFFFF" bgColor="000000" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="DELIMITERS1" fgColor="66FF00" bgColor="000000" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="DELIMITERS2" fgColor="66FF00" bgColor="000000" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="DELIMITERS3" fgColor="FFFFFF" bgColor="000000" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="DELIMITERS4" fgColor="FFFFFF" bgColor="000000" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="DELIMITERS5" fgColor="FFFFFF" bgColor="000000" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="DELIMITERS6" fgColor="FFFFFF" bgColor="000000" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="DELIMITERS7" fgColor="FFFFFF" bgColor="000000" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="DELIMITERS8" fgColor="FFFFFF" bgColor="000000" fontName="" fontStyle="0" nesting="0" />
        </Styles>
    </UserLang>
</NotepadPlus>

_________________


Top
 Profile  
 
PostPosted: Sat Oct 21, 2017 11:46 am 
Offline

Joined: Tue May 28, 2013 5:49 am
Posts: 874
Location: Sweden
Nice job! It seems it requires a dark background theme though. Mine requires a white background, I wish I knew how to make it universal.
I also have problem getting numbers to highlight correctly in certain situations.

Mine is more general than just ASM6 or 6502, it has mnemonics for 6502/8500/8502, 65C02, HuC6280 and 65816/65802. It's also not based on the default x86 highlighting and uses much more colours. Instead of supporting every directive of every assembler it simply uses "." and "@", used as many assemblers for directives or local labels, as prefixes. Mnemonics for common aliases and illegal opcodes are also included but in their own colours. SAX is an exception because it's a valid opcode on HuC6280 and is therefore also highlighted as such.

Check it out:
Code:
<NotepadPlus>
    <UserLang name="65x" ext="x65" udlVersion="2.1">
        <Settings>
            <Global caseIgnored="yes" allowFoldOfComments="no" foldCompact="no" forcePureLC="0" decimalSeparator="0" />
            <Prefix Keywords1="no" Keywords2="no" Keywords3="no" Keywords4="yes" Keywords5="no" Keywords6="no" Keywords7="no" Keywords8="no" />
        </Settings>
        <KeywordLists>
            <Keywords name="Comments">00; 00// 01 02 03 04</Keywords>
            <Keywords name="Numbers, prefix1"></Keywords>
            <Keywords name="Numbers, prefix2">$ % #$ #%</Keywords>
            <Keywords name="Numbers, extras1">A B C D E F a b c d e f</Keywords>
            <Keywords name="Numbers, extras2"></Keywords>
            <Keywords name="Numbers, suffix1"></Keywords>
            <Keywords name="Numbers, suffix2"></Keywords>
            <Keywords name="Numbers, range"></Keywords>
            <Keywords name="Operators1">( ) [ ] { } &lt; &gt; + - * / | = ~ ^ &amp; ! , :</Keywords>
            <Keywords name="Operators2"></Keywords>
            <Keywords name="Folders in code1, open"></Keywords>
            <Keywords name="Folders in code1, middle"></Keywords>
            <Keywords name="Folders in code1, close"></Keywords>
            <Keywords name="Folders in code2, open"></Keywords>
            <Keywords name="Folders in code2, middle"></Keywords>
            <Keywords name="Folders in code2, close"></Keywords>
            <Keywords name="Folders in comment, open"></Keywords>
            <Keywords name="Folders in comment, middle"></Keywords>
            <Keywords name="Folders in comment, close"></Keywords>
            <Keywords name="Keywords1">and asl bit clc cld cli clv eor lda ldx ldy lsr ora pha php pla plp rol ror sec sed sei sta stx sty phx phy plx ply stz trb tsb rmb0 rmb1 rmb2 rmb3 rmb4 rmb5 rmb6 rmb7 smb0 smb1 smb2 smb3 smb4 smb5 smb6 smb7 mvn mvp pea pei per phb phd phk plb pld rep sep cla clx cly csh csl set st0 st1 st2 tst</Keywords>
            <Keywords name="Keywords2">bcc bcs beq bmi bne bpl brk bvc bvs cmp cpx cpy jmp jsr nop rti rts bra bbr0 bbr1 bbr2 bbr3 bbr4 bbr5 bbr6 bbr7 bbs0 bbs1 bbs2 bbs3 bbs4 bbs5 bbs6 bbs7 stp wai brl cop jml jsl rtl wdm bsr</Keywords>
            <Keywords name="Keywords3">adc dec dex dey inc inx iny sbc tax tay tsx txa txs tya tcd tcs tdc tsc txy tyx xba xce sax say sxy tai tam tdd tia tii tin tma</Keywords>
            <Keywords name="Keywords4">. @</Keywords>
            <Keywords name="Keywords5">A X Y</Keywords>
            <Keywords name="Keywords6">EQU INCLUDE INCSRC INCBIN DW DB BYTE WORD DL DH HEX DSB DSW PAD ORG ALIGN FILLVALUE BASE IF ELSEIF ELSE ENDIF IFDEF IFNDEF MACRO ENDM REPT ENDR ENUM ENDE ERROR</Keywords>
            <Keywords name="Keywords7">bge blt cpa dea ina swa tad tas tda tsa</Keywords>
            <Keywords name="Keywords8">slo rla sre rra lax dcp isc anc alr arr xaa axs ahx shx shy las kil aso lse isb asr a11 lar jam hlt sbx</Keywords>
            <Keywords name="Delimiters">00&quot; 01 02&quot; 03&apos; 04 05&apos; 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23</Keywords>
        </KeywordLists>
        <Styles>
            <WordsStyle name="DEFAULT" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="COMMENTS" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="LINE COMMENTS" fgColor="008000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="NUMBERS" fgColor="FF8000" bgColor="FFFFFF" fontName="" fontStyle="1" nesting="0" />
            <WordsStyle name="KEYWORDS1" fgColor="FF0000" bgColor="FFFFFF" fontName="" fontStyle="1" nesting="0" />
            <WordsStyle name="KEYWORDS2" fgColor="0000FF" bgColor="FFFFFF" fontName="" fontStyle="1" nesting="0" />
            <WordsStyle name="KEYWORDS3" fgColor="FF8000" bgColor="FFFFFF" fontName="" fontStyle="1" nesting="0" />
            <WordsStyle name="KEYWORDS4" fgColor="0080C0" bgColor="FFFFFF" fontName="" fontStyle="1" nesting="0" />
            <WordsStyle name="KEYWORDS5" fgColor="8000FF" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="KEYWORDS6" fgColor="0080FF" bgColor="FFFFFF" fontName="" fontStyle="1" nesting="0" />
            <WordsStyle name="KEYWORDS7" fgColor="808000" bgColor="FFFFFF" fontName="" fontStyle="1" nesting="0" />
            <WordsStyle name="KEYWORDS8" fgColor="8000FF" bgColor="FFFFFF" fontName="" fontStyle="1" nesting="0" />
            <WordsStyle name="OPERATORS" fgColor="FF5BFF" bgColor="FFFFFF" fontName="" fontStyle="1" nesting="0" />
            <WordsStyle name="FOLDER IN CODE1" fgColor="800080" bgColor="FFFFFF" fontName="" fontStyle="1" nesting="0" />
            <WordsStyle name="FOLDER IN CODE2" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="FOLDER IN COMMENT" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="DELIMITERS1" fgColor="FF0000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="DELIMITERS2" fgColor="FF0000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="DELIMITERS3" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="DELIMITERS4" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="DELIMITERS5" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="DELIMITERS6" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="DELIMITERS7" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
            <WordsStyle name="DELIMITERS8" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
        </Styles>
    </UserLang>
</NotepadPlus>


Top
 Profile  
 
PostPosted: Sat Oct 21, 2017 5:57 pm 
Offline
User avatar

Joined: Mon Oct 20, 2014 1:50 pm
Posts: 94
Wow, thanks for sharing! And for giving it in [code] instead of a link. I knew people would have better UDLs than me, but I put up the thread anyways because I was tired of finding dead links left and right. This will go a long way towards preventing future frustration for people using search engines.

I'll have to give this x65 highlighting a shot. Using the prefix mode to get the . and @ sounds clever. And at a glance you seemed to do a more elegant job at handling number prefixes.

_________________


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: Bing [Bot], DRW, Ti_, Yahoo [Bot] and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group