Syntax highlighter for pasm in Sublime Text 3

I’m programming the BBB’s PRU in pasm. Does anyone know how I can get Sublime Text to color the code (syntax highlight)?

I cross-posted here:

http://stackoverflow.com/questions/41774562/pasm-syntax-highlighting-in-sublime-text-3

Thanks.
-Justin

Hi!

I don’t know SublimeText and can’t help on topic. But in addition to the TI configurations, I can provide pasm highlighting for Geany IDE, if you’re interested.

Regards

You can write your own syntax highlighter for Sublime Text3. I say this, because I’ve never seen any assembly language highlighting for Sublime text period. And yes, I do use Sublime text myself( for the last 4-5 years ). You might try using C highlighting, to see if the standard C highlighting also highlights inline assembly. But that’s doubtful.

I was looking a while back for something similar, and the only thing I found was someone on parallax’s forum’s talking about having writen a syntax highlighter for Visual Studio Code( not to be confused with the Visual studio IDE ) and the p2asm language. Maybe It’s possible to adapt that, or in a pinch just use it in code. I’ve been using VSC myself recently a lot for javascript, C, and C++. It’s not a bad text editor at all.

Thanks William & TJF. Following your advice I wrote my own syntax
highlighting file for pasm (for Sublime Text 3):

https://github.com/justinpearson/pasm-sublime-text-syntax-highlight

Best,
Justin

Awesome !

TJF, would you post your pasm highlighter for Geany?

Thanks,
Justin

BTW, I tried to add a link to this pasm syntax highlighter to the official TI pasm wiki page:

http://processors.wiki.ti.com/index.php/PASM_Syntax_Highlighting

… but I got an “Access Denied” error.

-Justin

Here you are:

`

For complete documentation of this file, please see Geany’s main documentation

[styling]

foreground;background;bold;italic

default=0x900000;0xffffff;false;false
comment=0x808080;0xffffff;false;false
number=0x007f00;0xffffff;false;false
string=0xff901e;0xffffff;false;false
operator=0x000000;0xffffff;false;false
identifier=0x880000;0xffffff;false;false
cpuinstruction=0x111199;0xffffff;false;false
mathinstruction=0x7f0000;0xffffff;false;false
register=0x000000;0xffffff;false;false
directive=0x3d670f;0xffffff;false;false
directiveoperand=0xff901e;0xffffff;false;false
commentblock=0x808080;0xffffff;false;false
character=0xff901e;0xffffff;false;false
stringeol=0x000000;0xe0c0e0;false;false
extinstruction=0x007f7f;0xffffff;false;false

[keywords]

all items must be in one line

instructions=add adc sub suc rsb rsc lsl lsr and or xor not min max clr set scan lmbd mov ldi mvi lbbo sbbo lbco sbco lfc stc zero jmp jal call ret qbgt qbge qblt qble qbeq qbne qba qbbs qbbc wbs wbc halt slp loop fill
registers=c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16 c17 c18 c19 c20 c21 c22 c23 c24 c25 c26 c27 c28 c29 c30 c31 r0 r1 r2 r3 r4 r5 r6 r7 r8 r9 r10 r11 r12 r13 r14 r15 r16 r17 r18 r19 r20 r21 r22 r23 r24 r25 r26 r27 r28 r29 r30 r31
directives=.origin .entrypoint .setcallreg .struct .ends .u32 .u16 .u8 .assign .enter .leave .using .macro .mparam .endm
Extended instructions=#define #else #endif #if #ifdef #ifndef #include #elseif #error #note #warn

[settings]

default extension used when saving files

extension=p

single comments, like # in this file

comment_single=//

This setting works only for single line comments

comment_use_indent=true

lexer_filetype=ASM

context action command (please see Geany’s main documentation for details)

context_action_cmd=

[indentation]
width=2

0 is spaces, 1 is tabs, 2 is tab & spaces

type=0

[build_settings]

%f will be replaced by the complete filename

%e will be replaced by the filename without extension

(use only one of it at one time)

compiler=pasm_2 -b -y “%f”

`

File lives in geany/filedefs/filetypes.pasm.conf.

Regards

Thanks TJF. Geany does syntax-highlighting a lot more simply than Sublime Text. In ST you don’t pick the colors for keywords; instead, you use regexps to assign semantic meaning to certain strings, like a string matching “\b[0-9]+\b” (a number) is assigned type “constant.numeric” whereas a string matching “\b[rR]\d\d?\b” (a register) is assigned type “storage”. Depending on the ST “theme” you’re using, those types get colored differently.

What a complicated world!

-Justin

This file does more than highlighting definitions. Ie. you can configure compiler commands or set some default custom commands for the specified file type.

For color declaration there’s a similar system in Geany. You can define named colors in the file filetypes.common and then use those names instead of a fixed setting (I’m not sure why I used the fixed setting here).

One reason why I use Geany is that it scrolls much faster than editors based on regex lexers.

Regards