From 0ea33fb9f5da4f99a9a663443917a7dc2dd9495f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix?= <142559040+filouRE@users.noreply.github.com> Date: Sat, 12 Oct 2024 19:06:05 -0400 Subject: [PATCH] working --- README.md | 115 ++++++++++++++++++----------- language-configuration.json | 8 +- package.json | 31 ++++---- syntaxes/asm.tmLanguage.json | 32 -------- syntaxes/x86asm.tmLanguage.json | 127 ++++++++++++++++++++++++++++++++ 5 files changed, 216 insertions(+), 97 deletions(-) delete mode 100644 syntaxes/asm.tmLanguage.json create mode 100644 syntaxes/x86asm.tmLanguage.json diff --git a/README.md b/README.md index 007cf0f..20ec9a2 100644 --- a/README.md +++ b/README.md @@ -1,65 +1,90 @@ -# x86-x64-syntax-highlighting README +# VS Code x86/x64 Assembly Syntax Highlighting Extension -This is the README for your extension "x86-x64-syntax-highlighting". After writing up a brief description, we recommend including the following sections. +## Overview + +This Visual Studio Code extension provides comprehensive syntax highlighting for x86 and x64 assembly language using Intel syntax. It's designed to improve readability and understanding of assembly code, including compiler-generated output. ## Features -Describe specific features of your extension including screenshots of your extension in action. Image paths are relative to this README file. +- Syntax highlighting for x86 and x64 assembly instructions +- Support for Intel syntax +- Highlighting of registers, memory operands, and numeric constants +- Recognition of common assembler directives +- Proper highlighting of labels and function names +- Support for compiler-generated assembly features (e.g., CFI directives) -For example if there is an image subfolder under your extension project workspace: +## Installation -\!\[feature X\]\(images/feature-x.png\) +1. Open Visual Studio Code +2. Go to the Extensions view (Ctrl+Shift+X or Cmd+Shift+X on macOS) +3. Search for "x86/x64 Assembly Syntax Highlighting" +4. Click Install -> Tip: Many popular extensions utilize animations. This is an excellent way to show off your extension! We recommend short, focused animations that are easy to follow. +Alternatively, you can download the VSIX file from the releases page and install it manually: -## Requirements +1. Download the `.vsix` file +2. In VS Code, go to the Extensions view +3. Click on the "..." at the top of the Extensions view +4. Choose "Install from VSIX..." and select the downloaded file -If you have any requirements or dependencies, add a section describing those and how to install and configure them. +## Usage -## Extension Settings +Once installed, the extension will automatically provide syntax highlighting for files with the following extensions: -Include if your extension adds any VS Code settings through the `contributes.configuration` extension point. +- `.asm` +- `.s` + +If you're working with a file that has a different extension but contains x86/x64 assembly code, you can manually set the language mode: + +1. Click on the language indicator in the bottom-right corner of VS Code +2. Select "x86/x64 Assembly" from the list of languages + +## Highlighted Elements + +This extension provides syntax highlighting for: + +- Instructions (e.g., `mov`, `push`, `call`) +- Registers (e.g., `eax`, `rbp`, `r15`) +- Memory operands (e.g., `DWORD PTR`, `QWORD PTR`) +- Numeric constants (decimal and hexadecimal) +- Labels and function names +- Assembler directives (e.g., `.section`, `.globl`) +- CFI directives (e.g., `.cfi_startproc`, `.cfi_endproc`) +- Comments (lines starting with `;`) + +## Customization + +You can customize the colors used for syntax highlighting by modifying your VS Code color theme. Add or modify entries in your `settings.json` file under `"editor.tokenColorCustomizations"`. For example: -This extension contributes the following settings: +```json +"editor.tokenColorCustomizations": { + "textMateRules": [ + { + "scope": "keyword.control.instruction.x86asm", + "settings": { + "foreground": "#C678DD" + } + }, + { + "scope": "variable.language.register.x86asm", + "settings": { + "foreground": "#E06C75" + } + } + ] +} +``` -* `myExtension.enable`: Enable/disable this extension. -* `myExtension.thing`: Set to `blah` to do something. +## Contributing -## Known Issues +If you find any issues or have suggestions for improvements, please open an issue or submit a pull request on the GitHub repository. -Calling out known issues can help limit users opening duplicate issues against your extension. +## License -## Release Notes +This extension is released under the MIT License. See the LICENSE file for details. -Users appreciate release notes as you update your extension. +## Acknowledgements -### 1.0.0 - -Initial release of ... - -### 1.0.1 - -Fixed issue #. - -### 1.1.0 - -Added features X, Y, and Z. - ---- - -## Working with Markdown - -You can author your README using Visual Studio Code. Here are some useful editor keyboard shortcuts: - -* Split the editor (`Cmd+\` on macOS or `Ctrl+\` on Windows and Linux). -* Toggle preview (`Shift+Cmd+V` on macOS or `Shift+Ctrl+V` on Windows and Linux). -* Press `Ctrl+Space` (Windows, Linux, macOS) to see a list of Markdown snippets. - -## For more information - -* [Visual Studio Code's Markdown Support](http://code.visualstudio.com/docs/languages/markdown) -* [Markdown Syntax Reference](https://help.github.com/articles/markdown-basics/) - -**Enjoy!** +Thanks to all contributors and users who have provided feedback and suggestions to improve this extension. diff --git a/language-configuration.json b/language-configuration.json index 8f162a0..7d69207 100644 --- a/language-configuration.json +++ b/language-configuration.json @@ -1,17 +1,12 @@ { "comments": { - // symbol used for single line comment. Remove this entry if your language does not support line comments - "lineComment": "//", - // symbols used for start and end a block comment. Remove this entry if your language does not support block comments - "blockComment": [ "/*", "*/" ] + "lineComment": ";" }, - // symbols used as brackets "brackets": [ ["{", "}"], ["[", "]"], ["(", ")"] ], - // symbols that are auto closed when typing "autoClosingPairs": [ ["{", "}"], ["[", "]"], @@ -19,7 +14,6 @@ ["\"", "\""], ["'", "'"] ], - // symbols that can be used to surround a selection "surroundingPairs": [ ["{", "}"], ["[", "]"], diff --git a/package.json b/package.json index 0363a33..00156dc 100644 --- a/package.json +++ b/package.json @@ -1,25 +1,30 @@ { - "name": "x86-x64-syntax-highlighting", - "displayName": "x86-x64 Syntax Highlighting", - "description": "This is an x86-64 Assembly Syntax Highlighter", - "version": "0.0.1", + "name": "x86-assembly-syntax", + "displayName": "x86/x64 Assembly Syntax", + "description": "Syntax highlighting for x86/x64 assembly with Intel syntax", + "version": "0.0.2", "engines": { - "vscode": "^1.94.0" + "vscode": "^1.60.0" }, "categories": [ "Programming Languages" ], "contributes": { "languages": [{ - "id": "asm", - "aliases": ["assembly", "asm"], - "extensions": [".s",".asm"], + "id": "x86asm", + "aliases": ["x86/x64 Assembly", "x86asm"], + "extensions": [".asm",".s"], "configuration": "./language-configuration.json" }], "grammars": [{ - "language": "asm", - "scopeName": "", - "path": "./syntaxes/asm.tmLanguage.json" + "language": "x86asm", + "scopeName": "source.x86asm", + "path": "./syntaxes/x86asm.tmLanguage.json" }] - } -} + }, + "repository": { + "type": "git", + "url": "https://github.com/haxo-games/x86-x64-syntax-highlighting.git" + }, + "publisher": "YourPublisherName" +} \ No newline at end of file diff --git a/syntaxes/asm.tmLanguage.json b/syntaxes/asm.tmLanguage.json deleted file mode 100644 index 9595972..0000000 --- a/syntaxes/asm.tmLanguage.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json", - "name": "assembly", - "patterns": [ - { - "include": "#keywords" - }, - { - "include": "#strings" - } - ], - "repository": { - "keywords": { - "patterns": [{ - "name": "keyword.control.asm", - "match": "\\b(if|while|for|return)\\b" - }] - }, - "strings": { - "name": "string.quoted.double.asm", - "begin": "\"", - "end": "\"", - "patterns": [ - { - "name": "constant.character.escape.asm", - "match": "\\\\." - } - ] - } - }, - "scopeName": "" -} \ No newline at end of file diff --git a/syntaxes/x86asm.tmLanguage.json b/syntaxes/x86asm.tmLanguage.json new file mode 100644 index 0000000..37cc984 --- /dev/null +++ b/syntaxes/x86asm.tmLanguage.json @@ -0,0 +1,127 @@ +{ + "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json", + "name": "x86/x64 Assembly", + "patterns": [ + { "include": "#comments" }, + { "include": "#strings" }, + { "include": "#constants" }, + { "include": "#registers" }, + { "include": "#instructions" }, + { "include": "#directives" }, + { "include": "#labels" }, + { "include": "#sections" }, + { "include": "#symbols" }, + { "include": "#functions" }, + { "include": "#memory_operands" } + ], + "repository": { + "comments": { + "patterns": [ + { + "name": "comment.line.semicolon.x86asm", + "match": ";.*$" + } + ] + }, + "strings": { + "name": "string.quoted.double.x86asm", + "begin": "\"", + "end": "\"", + "patterns": [ + { + "name": "constant.character.escape.x86asm", + "match": "\\\\." + } + ] + }, + "constants": { + "patterns": [ + { + "name": "constant.numeric.hex.x86asm", + "match": "\\b(0x[0-9A-Fa-f]+)\\b" + }, + { + "name": "constant.numeric.decimal.x86asm", + "match": "\\b([0-9]+)\\b" + } + ] + }, + "registers": { + "patterns": [ + { + "name": "variable.language.register.x86asm", + "match": "\\b(rax|rbx|rcx|rdx|rsi|rdi|rbp|rsp|r8|r9|r10|r11|r12|r13|r14|r15|eax|ebx|ecx|edx|esi|edi|ebp|esp|ax|bx|cx|dx|si|di|bp|sp|al|bl|cl|dl)\\b" + } + ] + }, + "instructions": { + "patterns": [ + { + "name": "keyword.control.instruction.x86asm", + "match": "\\b(mov|push|pop|call|ret|leave|jmp|je|jne|jz|jnz|add|sub|mul|div|and|or|xor|lea|cmp|test|inc|dec|shl|shr|nop|enter)\\b" + } + ] + }, + "directives": { + "patterns": [ + { + "name": "keyword.control.directive.x86asm", + "match": "\\.(file|intel_syntax|section|text|data|bss|rdata|rodata|globl|local|comm|lcomm|def|scl|type|size|align|ascii|asciz|byte|word|long|quad|space|equ|set|cfi_startproc|cfi_endproc|cfi_def_cfa|cfi_def_cfa_register|cfi_adjust_cfa_offset|cfi_offset|cfi_escape|cfi_restore|ident)\\b" + }, + { + "name": "keyword.control.directive.option.x86asm", + "match": "\\bnoprefix\\b" + } + ] + }, + "labels": { + "patterns": [ + { + "name": "entity.name.function.label.x86asm", + "match": "^[a-zA-Z_][a-zA-Z0-9_]*:" + }, + { + "name": "entity.name.tag.label.x86asm", + "match": "^L[a-zA-Z0-9_]+:" + } + ] + }, + "sections": { + "patterns": [ + { + "name": "entity.name.section.x86asm", + "match": "\\.(text|data|bss|rdata|rodata|comment)\\b" + } + ] + }, + "symbols": { + "patterns": [ + { + "name": "variable.other.symbol.x86asm", + "match": "\\b__[A-Za-z0-9_]+\\b" + } + ] + }, + "functions": { + "patterns": [ + { + "name": "support.function.x86asm", + "match": "\\b(_*[a-zA-Z_][a-zA-Z0-9_]*)\\b" + } + ] + }, + "memory_operands": { + "patterns": [ + { + "name": "storage.type.memory.x86asm", + "match": "\\b(BYTE|WORD|DWORD|QWORD|XMMWORD|YMMWORD|ZMMWORD)\\s+PTR\\b" + }, + { + "name": "storage.type.memory.x86asm", + "match": "\\b(TBYTE|TWORD|DQWORD|OWORD|FWORD)\\b" + } + ] + } + }, + "scopeName": "source.x86asm" +} \ No newline at end of file