From bcf10cc7c2c3381769c824515a45da6e12c15dac Mon Sep 17 00:00:00 2001 From: Andrzej Lichnerowicz Date: Fri, 23 Feb 2024 19:32:01 +0100 Subject: [PATCH] Add Lexer for NDISASM The Netwide Disassembler outputs text that is assembly prefixed with memory offsets and opcode bytes. --- lexers/embedded/ndisasm.xml | 123 +++++++++++++++++++++++++++++++ lexers/testdata/ndisasm.actual | 12 +++ lexers/testdata/ndisasm.expected | 108 +++++++++++++++++++++++++++ 3 files changed, 243 insertions(+) create mode 100644 lexers/embedded/ndisasm.xml create mode 100644 lexers/testdata/ndisasm.actual create mode 100644 lexers/testdata/ndisasm.expected diff --git a/lexers/embedded/ndisasm.xml b/lexers/embedded/ndisasm.xml new file mode 100644 index 000000000..74d443b64 --- /dev/null +++ b/lexers/embedded/ndisasm.xml @@ -0,0 +1,123 @@ + + + NDISASM + ndisasm + text/x-disasm + true + 0.5 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/lexers/testdata/ndisasm.actual b/lexers/testdata/ndisasm.actual new file mode 100644 index 000000000..911bc0d24 --- /dev/null +++ b/lexers/testdata/ndisasm.actual @@ -0,0 +1,12 @@ +00000000 B013 mov al,0x13 +00000002 CD10 int 0x10 +00000004 B9027D mov cx,0x7d02 +00000007 51 push cx +00000008 6800A0 push word 0xa000 +0000000B 07 pop es +0000000C B00F mov al,0xf +0000000E F3AA rep stosb +00000010 59 pop cx +00000011 B004 mov al,0x4 +00000013 F3AA rep stosb +00000015 CD16 int 0x16 diff --git a/lexers/testdata/ndisasm.expected b/lexers/testdata/ndisasm.expected new file mode 100644 index 000000000..13127a83e --- /dev/null +++ b/lexers/testdata/ndisasm.expected @@ -0,0 +1,108 @@ +[ + {"type":"CommentSpecial","value":"00000000"}, + {"type":"Text","value":" "}, + {"type":"CommentSpecial","value":"B013"}, + {"type":"Text","value":" "}, + {"type":"NameFunction","value":"mov"}, + {"type":"Text","value":" "}, + {"type":"NameBuiltin","value":"al"}, + {"type":"Punctuation","value":","}, + {"type":"LiteralNumberHex","value":"0x13"}, + {"type":"Text","value":"\n"}, + {"type":"CommentSpecial","value":"00000002"}, + {"type":"Text","value":" "}, + {"type":"CommentSpecial","value":"CD10"}, + {"type":"Text","value":" "}, + {"type":"NameFunction","value":"int"}, + {"type":"Text","value":" "}, + {"type":"LiteralNumberHex","value":"0x10"}, + {"type":"Text","value":"\n"}, + {"type":"CommentSpecial","value":"00000004"}, + {"type":"Text","value":" "}, + {"type":"CommentSpecial","value":"B9027D"}, + {"type":"Text","value":" "}, + {"type":"NameFunction","value":"mov"}, + {"type":"Text","value":" "}, + {"type":"NameBuiltin","value":"cx"}, + {"type":"Punctuation","value":","}, + {"type":"LiteralNumberHex","value":"0x7d02"}, + {"type":"Text","value":"\n"}, + {"type":"CommentSpecial","value":"00000007"}, + {"type":"Text","value":" "}, + {"type":"CommentSpecial","value":"51"}, + {"type":"Text","value":" "}, + {"type":"NameFunction","value":"push"}, + {"type":"Text","value":" "}, + {"type":"NameBuiltin","value":"cx"}, + {"type":"Text","value":"\n"}, + {"type":"CommentSpecial","value":"00000008"}, + {"type":"Text","value":" "}, + {"type":"CommentSpecial","value":"6800A0"}, + {"type":"Text","value":" "}, + {"type":"NameFunction","value":"push"}, + {"type":"Text","value":" "}, + {"type":"KeywordType","value":"word"}, + {"type":"Text","value":" "}, + {"type":"LiteralNumberHex","value":"0xa000"}, + {"type":"Text","value":"\n"}, + {"type":"CommentSpecial","value":"0000000B"}, + {"type":"Text","value":" "}, + {"type":"CommentSpecial","value":"07"}, + {"type":"Text","value":" "}, + {"type":"NameFunction","value":"pop"}, + {"type":"Text","value":" "}, + {"type":"NameBuiltin","value":"es"}, + {"type":"Text","value":"\n"}, + {"type":"CommentSpecial","value":"0000000C"}, + {"type":"Text","value":" "}, + {"type":"CommentSpecial","value":"B00F"}, + {"type":"Text","value":" "}, + {"type":"NameFunction","value":"mov"}, + {"type":"Text","value":" "}, + {"type":"NameBuiltin","value":"al"}, + {"type":"Punctuation","value":","}, + {"type":"LiteralNumberHex","value":"0xf"}, + {"type":"Text","value":"\n"}, + {"type":"CommentSpecial","value":"0000000E"}, + {"type":"Text","value":" "}, + {"type":"CommentSpecial","value":"F3AA"}, + {"type":"Text","value":" "}, + {"type":"NameFunction","value":"rep"}, + {"type":"Text","value":" "}, + {"type":"NameVariable","value":"stosb"}, + {"type":"Text","value":"\n"}, + {"type":"CommentSpecial","value":"00000010"}, + {"type":"Text","value":" "}, + {"type":"CommentSpecial","value":"59"}, + {"type":"Text","value":" "}, + {"type":"NameFunction","value":"pop"}, + {"type":"Text","value":" "}, + {"type":"NameBuiltin","value":"cx"}, + {"type":"Text","value":"\n"}, + {"type":"CommentSpecial","value":"00000011"}, + {"type":"Text","value":" "}, + {"type":"CommentSpecial","value":"B004"}, + {"type":"Text","value":" "}, + {"type":"NameFunction","value":"mov"}, + {"type":"Text","value":" "}, + {"type":"NameBuiltin","value":"al"}, + {"type":"Punctuation","value":","}, + {"type":"LiteralNumberHex","value":"0x4"}, + {"type":"Text","value":"\n"}, + {"type":"CommentSpecial","value":"00000013"}, + {"type":"Text","value":" "}, + {"type":"CommentSpecial","value":"F3AA"}, + {"type":"Text","value":" "}, + {"type":"NameFunction","value":"rep"}, + {"type":"Text","value":" "}, + {"type":"NameVariable","value":"stosb"}, + {"type":"Text","value":"\n"}, + {"type":"CommentSpecial","value":"00000015"}, + {"type":"Text","value":" "}, + {"type":"CommentSpecial","value":"CD16"}, + {"type":"Text","value":" "}, + {"type":"NameFunction","value":"int"}, + {"type":"Text","value":" "}, + {"type":"LiteralNumberHex","value":"0x16"}, + {"type":"Text","value":"\n"} +]