1

Texas Instruments has a custom assembly language for its programmable real-time unit subsystems (PRUSS). TI provides syntax files for Notepad++ and Textpad, but I cannot find any syntax files for Vim. I'd be a bit surprised if no one had made on yet, though.

For now, I'm using ft=c, which is okay but not ideal.

  • Kyle, feel free to create a plugin... just don't forget to share... :-) Bryan – Bryan Wilcutt Jan 14 '16 at 19:00
2

EDIT: There is now a plugin made by copying the syntax file below: https://github.com/laubzega/pruss-vim

Here's my own PRU vim syntax highlighter with instructions:

mkdir ~/.vim/syntax
mkdir ~/.vim/ftdetect

cd ~/.vim/ftdetect
vi pruft.vim

Insert and save the following:

au BufRead,BufNewFile *.p       set filetype=pru
au BufRead,BufNewFile *.hp      set filetype=pru

Return back to your terminal.

cd ~/.vim/syntax
vi pru.vim

Insert and save the following:

" Vim syntax file for PRU
" Created by Bryan Wilcutt

if exists ("b:current_syntax")
    finish
endif

" Define keywords from PRU
syn keyword syntaxElementKeyword add adc sub suc rsb rsc lsl lsr and or xor not min max 
syn keyword syntaxElementKeyword clr set scan lmbd mov ldi mvib mviw mvid lbbo sbbo lbco sbco
syn keyword syntaxElementKeyword zero jmp jal call ret qbgt qbge qblt qble qbeq qbne qba 
syn keyword syntaxElementKeyword qbbs qbbc wbs wbc halt slp 

syn keyword syntaxElementKeyword ADD ADC SUB SUC RSB RSC LSL LSR AND OR XOR NOT MIN MAX 
syn keyword syntaxElementKeyword CLR SET SCAN LMBD MOV LDI MVIB MVIW MVID LBBO SBBO LBCO SBCO
syn keyword syntaxElementKeyword ZERO JMP JAL CALL RET QBGT QBGE QBLT QBLE QBEQ QBNE QBA 
syn keyword syntaxElementKeyword QBBS QBBC WBS WBC HALT SLP 
hi def link syntaxElementKeyword Statement

" Define registers from PRU

syn keyword registerKeyword r0 r1 r2 r3 r4 r5 r6 r7 r8 r9 r10 r11 r12 r13 r14 r15 
syn keyword registerKeyword r16 r17 r18 r19 r20 r21 r22 r23 r24 r25 r26 r27 r28 r29 r30 r31 

syn keyword registerKeyword R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 
syn keyword registerKeyword R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 R30 R31 

syn match regPartBit '.t\d\+' contains=registerKeyword
syn match regPartWord '.w\d\+' contains=registerKeyword

hi def link registerKeyword PreProc
hi def link regPartBit PreProc
hi def link regPartWord PreProc

" Preprocessor commands

syn keyword preprocWord setcallreg entrypoint origin assign enter leave using macro mparam endm struct ends
syn keyword preprocType u32 u16 u8
hi def link preprocWord PreProc
hi def link preprocType Type


" Define constant registers from PRU

syn keyword constantKeyword c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 
syn keyword constantKeyword c16 c17 c18 c19 c20 c21 c22 c23 c24 c25 c26 c27 c28 c29 c30 c31 

syn keyword constantKeyword C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 C10 C11 C12 C13 C14 C15 
syn keyword constantKeyword C16 C17 C18 C19 C20 C21 C22 C23 C24 C25 C26 C27 C28 C29 C30 C31 

hi def link constantKeyword PreProc

" Define comments

syn match synComment "//.*$"
hi def link synComment Comment

Restart your vim session.

The syntax highlighter isn't perfect but good enough for my own use while writing PRU assembler code.

  • Not a bad start! But it would be much more useable as a plugin. Do you mind if I create one? (Or you could make one yourself.) – Kyle Strand Dec 29 '15 at 18:38
  • I've gone ahead and made one: github.com/BatmanAoD/pruss-vim – Kyle Strand Jan 14 '16 at 19:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.