Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for ARM Assembly #3376

Merged
merged 2 commits into from Mar 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion components.js

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions components.json
Expand Up @@ -139,6 +139,11 @@
"title": "ARFF",
"owner": "Golmote"
},
"armasm": {
"title": "ARM Assembly",
"alias": "arm-asm",
"owner": "RunDevelopment"
},
"asciidoc": {
"alias": "adoc",
"title": "AsciiDoc",
Expand Down
49 changes: 49 additions & 0 deletions components/prism-armasm.js
@@ -0,0 +1,49 @@
Prism.languages.armasm = {
'comment': {
pattern: /;.*/,
greedy: true
},
'string': {
pattern: /"(?:[^"\r\n]|"")*"/,
greedy: true,
inside: {
'variable': {
pattern: /((?:^|[^$])(?:\${2})*)\$\w+/,
lookbehind: true
}
}
},
'char': {
pattern: /'(?:[^'\r\n]{0,4}|'')'/,
greedy: true
},
'version-symbol': {
pattern: /\|[\w@]+\|/,
greedy: true,
alias: 'property'
},

'boolean': /\b(?:FALSE|TRUE)\b/,
'directive': {
pattern: /\b(?:ALIAS|ALIGN|AREA|ARM|ASSERT|ATTR|CN|CODE|CODE16|CODE32|COMMON|CP|DATA|DCB|DCD|DCDO|DCDU|DCFD|DCFDU|DCI|DCQ|DCQU|DCW|DCWU|DN|ELIF|ELSE|END|ENDFUNC|ENDIF|ENDP|ENTRY|EQU|EXPORT|EXPORTAS|EXTERN|FIELD|FILL|FN|FUNCTION|GBLA|GBLL|GBLS|GET|GLOBAL|IF|IMPORT|INCBIN|INCLUDE|INFO|KEEP|LCLA|LCLL|LCLS|LTORG|MACRO|MAP|MEND|MEXIT|NOFP|OPT|PRESERVE8|PROC|QN|READONLY|RELOC|REQUIRE|REQUIRE8|RLIST|ROUT|SETA|SETL|SETS|SN|SPACE|SUBT|THUMB|THUMBX|TTL|WEND|WHILE)\b/,
alias: 'property'
},
'instruction': {
pattern: /((?:^|(?:^|[^\\])(?:\r\n?|\n))[ \t]*(?:(?:[A-Z][A-Z0-9_]*[a-z]\w*|[a-z]\w*|\d+)[ \t]+)?)\b[A-Z.]+\b/,
lookbehind: true,
alias: 'keyword'
},
'variable': /\$\w+/,

'number': /(?:\b[2-9]_\d+|(?:\b\d+(?:\.\d+)?|\B\.\d+)(?:e-?\d+)?|\b0(?:[fd]_|x)[0-9a-f]+|&[0-9a-f]+)\b/i,

'register': {
pattern: /\b(?:r\d|lr)\b/,
alias: 'symbol'
},

'operator': /<>|<<|>>|&&|\|\||[=!<>/]=?|[+\-*%#?&|^]|:[A-Z]+:/,
'punctuation': /[()[\],]/
};

Prism.languages['arm-asm'] = Prism.languages.armasm;
1 change: 1 addition & 0 deletions components/prism-armasm.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions examples/prism-armasm.html
@@ -0,0 +1,13 @@
<h2>Full example</h2>
<pre><code>; Source: https://developer.arm.com/documentation/dui0473/c/writing-arm-assembly-language/subroutines-calls
AREA subrout, CODE, READONLY ; Name this block of code
ENTRY ; Mark first instruction to execute
start MOV r0, #10 ; Set up parameters
MOV r1, #3
BL doadd ; Call subroutine
stop MOV r0, #0x18 ; angel_SWIreason_ReportException
LDR r1, =0x20026 ; ADP_Stopped_ApplicationExit
SVC #0x123456 ; ARM semihosting (formerly SWI)
doadd ADD r0, r0, r1 ; Subroutine code
BX lr ; Return from subroutine
END ; Mark end of file</code></pre>
1 change: 1 addition & 0 deletions plugins/autoloader/prism-autoloader.js
Expand Up @@ -176,6 +176,7 @@
"js": "javascript",
"g4": "antlr4",
"ino": "arduino",
"arm-asm": "armasm",
"adoc": "asciidoc",
"avs": "avisynth",
"avdl": "avro-idl",
Expand Down
2 changes: 1 addition & 1 deletion plugins/autoloader/prism-autoloader.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions plugins/show-language/prism-show-language.js
Expand Up @@ -38,6 +38,8 @@
"aql": "AQL",
"ino": "Arduino",
"arff": "ARFF",
"armasm": "ARM Assembly",
"arm-asm": "ARM Assembly",
"asciidoc": "AsciiDoc",
"adoc": "AsciiDoc",
"aspnet": "ASP.NET (C#)",
Expand Down