GeSHi Language File for PIC Assembler (18Fxxxx)
I occasionally use GeSHi on this site (via the GeSHi Filter Drupal module) to add syntax highlighting to code snippets, but usually not with PIC assembler.1
Even though it lists MPASM among its supported formats, GeSHi highlighting has always been uneven and incomplete, at least when applied to my PIC18F242-based code. For example:
It’s obvious that some opcodes and registers aren’t recognized, and bit names like TMR01E
and TMR0ON
are completely ignored. Identifying the TMR0H
register as TMR
plus 0H
is just annoying.
I saw that a relatively recent update added a “PIC16” format, and it definitely offered an improvement, which is to say, the opcodes were uniformly ignored:
Finally, I just decided to create a language file to suit my own needs. It’s far from exhaustive, but at least it identifies the registers on the chip I’m using, as well as fuse values, segment identifiers, bit names, and preprocessor directives supported by mpasm
and gpasm
. Here’s the kind of highlighting I’ve been looking for:
Still not perfect in every case, but GeSHi does a fairly good job for what it is. The GeSHi Filter module for Drupal provides a very convenient interface, so I’m satisfied with this solution for now. See Non-Responsive Flash Memory or Function Pointers in PIC Assembler for more extensive examples.
I have no intention of submitting this language file for inclusion in the official GeSHi release, so it doesn’t bother me that GeSHi’s langcheck.php
validation script complains about a few points (the file header comments don’t match a prescribed format, the tab spacing is wrong2, and the file is not described as part of GeSHi). It’s released under GPL v2, though (same as GeSHi), so feel free to use it however you see fit. [Download pic18.php]