Skip to content

Instantly share code, notes, and snippets.

@petabyt
Last active January 1, 2022 22:27
Show Gist options
  • Save petabyt/5dbfa413ff1b14e8c2b1af7c55249de6 to your computer and use it in GitHub Desktop.
Save petabyt/5dbfa413ff1b14e8c2b1af7c55249de6 to your computer and use it in GitHub Desktop.
Micro ARM Assembly
# ARM assembly language
# https://github.com/zyedidia/micro/issues/1562
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)(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"
## 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]+)\\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)"
# Data storage. Sorta types
- type: "(\\.ascii|\\.asciz|\\.byte|\\.hword|\\.word)"
# Single line comments
- comment:
start: "@"
end: "$"
rules:
- todo: "(TODO|XXX|FIXME):?"
# Block comments
- 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