diff --git a/msp430.js b/msp430.js new file mode 100644 index 0000000..897e6b7 --- /dev/null +++ b/msp430.js @@ -0,0 +1,26 @@ +// "MSP430 Assembly" language definition for highlight.js authored by John Breaux, 2023-06-26 +hljs.registerLanguage("msp430", function (r) { + return { + cI: !0, + l: "\\.?" + r.IR, + k: { + meta: ".byte .cseg .db .def .define .device .dseg .dw .endmacro .equ .eseg .exit .include .list .listmac .macro .nolist .org .set" + }, + c: [ + r.CBCM, // C block comments or C line comments + r.CLCM, + r.C(";", "$"), // Comments starting with ; and ending at EOL + { cN: "built_in", b: /@?\b(pc|sp|sr|cg|r1[0-5]|r[0-9])\b\+?/ }, + { cN: "keyword", b: /\b(adc|addc?|and|bi[cs]|bitb?|br|call|clr[cnz]?|cmp|dad[cd]|decd?|[de]int|incd?|inv|j([cz]|eq|ge|hs|lo?|mp|n[cez]?)|mov|[np]op|push|reti?|r[lr][ac]|sbc|set[cnz]|subc?|swpb|sxt|tst|xor)(\.[bw])?\b/ }, + { cN: "string", b: /['"]/, e: /[^\\]['"]/, i: /[^\\][^'"]/ }, + { cN: "meta", b: "<", e: ">" }, // MSProbe/Microcorruption specific: jump/call targets are placed in + { cN: "symbol", b: /^[A-Za-z0-9_.$]+:/ }, + { cN: "number", b: /\b[0-9a-fA-F]{4}\b/ }, + { cN: "number", b: /[#&]?-?\b(0o[0-7]+|(0x)?[0-9A-Fa-fx]+|\$[0-9A-Za-z]+)\b\(?/ }, + r.CNM, // highlight.js standard number parsers + r.BNM, + r.QSM, + { cN: "subst", b: "@[0-9]+" } // Accept numbers beginning with an @ + ] + } +});