Skip to content

Instantly share code, notes, and snippets.

@petabyt
Last active January 19, 2022 22:01
Show Gist options
  • Save petabyt/a52c0086e97209bbebdcb871aeddc800 to your computer and use it in GitHub Desktop.
Save petabyt/a52c0086e97209bbebdcb871aeddc800 to your computer and use it in GitHub Desktop.
correct micro arm assembly highlighting
# ARM assembly language
filetype: arm_asm
detect:
filename: "\\.(S)$"
rules:
## Instructions
# Load/store instructions
- statement: "\\b(?i)(ldc|ldm|ldr|ldrb|ldrh|stc|stm|str|strb|strh)(?-i)\\b"
# Branch instructions
- statement: "\\b(?i)(b|bl|bx|beq|bne|bcs|bcc|bmi|bpl|bvs|bvc|bhi|bls|bge|blt|bgt|ble)(?-i)\\b"
# Pseudo instructions
- statement: "\\b(?i)(push|pop)(?-i)\\b"
# Shift and rotate
- statement: "\\b(?i)(asl|asr|lsl|lsr|rol|ror)(?-i)\\b"
# Everything else
- statement: "\\b(?i)(adr|adc|add|and|bic|cdp|cmn|cmp|eor|mcr|mla|mov|mrc|mrs|mul|mvn|orr|rsb|rsc|sbc|sub|swi|swp|teq|tst)(?-i)\\b"
# Label
- special: ".*:"
## Registers
- identifier: "\\b(?i)(r[0-9]|r1[012345]|[fis]p|lr|pc|cpsr)(?-i)\\b"
## Constant numbers
# In immediates, with leading #
- constant.number: "#(0b[0-1]+|0x[0-9a-fA-F]+|[0-9]+)\\b"
# In directives, without leading #
- constant.number: "\\b([0-9]+|0x[0-9a-fA-F]+)\\b"
## Constant strings
# Strings, using double quotes
- constant.string:
start: "\""
end: "\""
skip: "\\\\."
rules:
- constant.specialChar: "\\\\."
# Characters, using single quotes
- constant.string:
start: "\'"
end: "\'"
skip: "\\\\."
rules:
- constant.specialChar: "\\\\."
# Directives. Sorta preprocessor
- preproc: "(\\.align|\\.balign|\\.data|\\.equ|\\.end|\\.extern|\\.func|\\.global|\\.section|\\.skip|\\.text|#include|#define|#ifdef|#ifndef|#endif|#error)"
# Data storage. Sorta types
- type: "(\\.ascii|\\.asciz|\\.byte|\\.hword|\\.word|\\.long)"
- comment:
start: "//"
end: "$"
rules:
- todo: "(TODO|XXX|FIXME):?"
- comment:
start: "/\\*"
end: "\\*/"
rules:
- todo: "(TODO|XXX|FIXME):?"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment