Skip to content

Commit

Permalink
fix #39 and improve assembly highlighting
Browse files Browse the repository at this point in the history
  • Loading branch information
matubu committed Jan 3, 2024
1 parent f9828a1 commit 8519954
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
8 changes: 7 additions & 1 deletion examples/languages/test.asm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ section .text
mov rsi, msg ; ABI is rdi, rsi
mov rdi, fmt
mov rax, 0 ; rax is # of non-int args

call printf

# https://github.com/speed-highlight/core/issues/39
vmovddup 2536(%rbx,%rax), %xmm1 # comment
vmovaps 2528(%rbx,%rax), %xmm3
vfmadd213ps %xmm6, %xmm5, %xmm3
vpslld $23, %xmm4, %xmm4

ret
14 changes: 11 additions & 3 deletions src/languages/asm.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,35 @@
export default [
{
type: 'cmnt',
match: /;.*/gm
match: /(;|#).*/gm
},
{
expand: 'str'
},
{
expand: 'num'
},
{
// value (ex: "$0x1")
type: 'num',
match: /\$[\da-fA-F]*\b/g
},
{
type: 'kwd',
match: /^[a-z]+\s+[a-z.]+/gm,
// ex: "section .data"
match: /^[a-z]+\s+[a-z.]+\b/gm,
sub: [
{
// keyword (ex: "section")
type: 'func',
match: /^[a-z]+/g
}
]
},
{
// instruction (ex: "mov")
type: 'kwd',
match: /^\t*[a-z]+/gm,
match: /^\t*[a-z][a-z\d]*\b/gm,
},
{
match: /%|\$/g,
Expand Down

0 comments on commit 8519954

Please sign in to comment.