汇编vim语法高亮

发布于 2024-07-18 01:50:42 字数 496 浏览 11 评论 0原文

默认的程序集语法文件效果不佳,在网上搜索有关 Gas 程序集的信息时,我没有找到任何有关 vim 的 Gas (AT&T) 语法文件的信息。 有人发现这个吗? 我无法编写自己的语法文件。

http://img168.imageshack.us/img168/46/nasm.png ft=nasm

http://img160.imageshack.us/img160/5857/asm.png ft=asm(默认)

< a href="http://img164.imageshack.us/img164/8476/tasm.png">http://img164.imageshack.us/img164/8476/tasm.png ft=tasm

The default assembly syntax file didn't work well and searching the web about gas assembly I found nothing about a gas (AT&T) syntax file for vim. Has anyone found this? I can't write my own syntax file.

http://img168.imageshack.us/img168/46/nasm.png ft=nasm

http://img160.imageshack.us/img160/5857/asm.png ft=asm(default)

http://img164.imageshack.us/img164/8476/tasm.png ft=tasm

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

青春有你 2024-07-25 01:50:43

Vim/Nvim 如果无法检测特定文件类型,可以使用文件本身中的实际宏来告知它是什么,而不必分别运行 :set ft=nasm 命令打开文件的时间。

为此,请弄清楚文件类型的注释语法是什么,然后在文件末尾添加如下行:(例如对于 NASM

; vim:ft=nasm

此图还显示了语法突出显示的实际效果就像添加了该行后文件的外观一样。

输入图片此处描述

Vim/Nvim if unable to detect specific filetype can be told what it is with an actual macro in the file itself instead of having to run the :set ft=nasm command each time you open the file.

To do this, figure out what the comment syntax of the file type is and add a line like this to the end of your file: (e.g. for NASM)

; vim:ft=nasm

This image shows the syntax highlighting in action as well as how the file looks with the line added.

enter image description here

放我走吧 2024-07-25 01:50:42

这可能帮助您入门。 这更像是您正在寻找的吗?

刚刚进行了快速搜索 - 看起来内置了几种不同类型的汇编语法突出显示。您使用的是哪一种?

从 :help 语法 复制粘贴

Currently these syntax
files are included:
    asm     GNU assembly (the default)
    asm68k      Motorola 680x0 assembly
    asmh8300    Hitachi H-8300 version of GNU assembly
    ia64        Intel Itanium 64
 fasm Flat assemlby http://flatassembler.net
    masm        Microsoft assembly (probably works for any 80x86)
    nasm        Netwide assembly
    tasm        Turbo Assembly (with opcodes 80x86 up to Pentium, and
            MMX)
    pic     PIC assembly (currently for PIC16F84)

The most flexible is to add a line in your assembly file containing:
    :asmsyntax=nasm
Replace "nasm" with the name of the real assembly syntax.  This line must be
one of the first five lines in the file.

此附加 语法脚本 来自 vim .org

看起来您的屏幕截图正在使用默认的 asm 文件类型。
尝试一下

:set ft=nasm

,您应该会根据这些屏幕截图看到一些颜色变化。

ft=nasm< /a>

从上面的屏幕截图中,我对 fasm vim 语法进行了一些快速修改,并将其称为gasm。
可以在pastebin上此处找到它。

将其复制并粘贴到您的个人 .vim/syntax 或 vimfiles/syntax 目录中,并将其命名为gasm.vim
然后在你的汇编文件中:set ft=gasm

这个vim脚本依赖于以下形式的注释
% 评论
包括空间。
您可以在脚本的第 116 行看到这一点(或者根据需要更改它)。

请注意:不要复制行号。

This may get you started. Is that more like what you're looking for?

Just had a quick search - it looks like there are a few different sorts of assembly syntax highlighting built in. Which one are you using?

Copy-pasted from :help syntax

Currently these syntax
files are included:
    asm     GNU assembly (the default)
    asm68k      Motorola 680x0 assembly
    asmh8300    Hitachi H-8300 version of GNU assembly
    ia64        Intel Itanium 64
 fasm Flat assemlby http://flatassembler.net
    masm        Microsoft assembly (probably works for any 80x86)
    nasm        Netwide assembly
    tasm        Turbo Assembly (with opcodes 80x86 up to Pentium, and
            MMX)
    pic     PIC assembly (currently for PIC16F84)

The most flexible is to add a line in your assembly file containing:
    :asmsyntax=nasm
Replace "nasm" with the name of the real assembly syntax.  This line must be
one of the first five lines in the file.

This additional syntax script is from vim.org

It looks like your screenshot is using the default asm filetype.
Try

:set ft=nasm

and you should get some colour changes as per these screenshots.

ft=nasm

From your screenshots above I've made a couple of quick modifications to the fasm vim syntax and called it gasm.
It can be found here on pastebin.

Copy and paste that into your personal .vim/syntax or vimfiles/syntax directory and call it gasm.vim
Then in your assembly file :set ft=gasm

This vim script relies on comments being of the form
% comment
with the space included.
You can see this (or change it if you wish) on line 116 of the script.

Please note: Don't copy the line numbers.

纵情客 2024-07-25 01:50:42

我开始从头开始编写完整的 GNU as 语法。

语法文件可从 vim.org 获取:GNU 作为 X86 的语法
以及直接在 GitHub 上:GNU 作为 X86 的语法

除了它会识别的基本指令之外以下扩展 Intel / AMD 指令:

  • X86 通用指令集 (8086 - 686)
  • Katmai Streaming SIMD 指令(SSE - 又名 KNI、XMM、MMX2)
  • 在 Deschutes 中引入,但对于 SSE 支持是必要的
  • XSAVE 组(AVX 和扩展状态)
  • 通用内存操作
  • 中引入了新的 MMX 指令
  • Katmai AMD 增强型 3DNow ! (Athlon) 指令
  • Willamette SSE2 高速缓存指令
  • Willamette MMX 指令(SSE2 SIMD 整数指令)
  • Willamette Streaming SIMD 指令 (SSE2)
  • Prescott 新指令 (SSE3)
  • VMX 指令
  • 扩展页表 VMX 指令
  • Tejas 新指令 (SSSE3)
  • AMD SSE4A
  • 巴塞罗那新指令
  • Penryn新指令 (SSE4.1)
  • Nehalem 新指令 (SSE4.2)
  • AMD SSE5 指令
  • Intel SMX
  • Geode (Cyrix) 3DNow! Intel
  • Intel AES 指令
  • AVX AES 指令
  • Intel AVX 指令
  • Intel 无进位乘法指令 (CLMUL)
  • Intel AVX 无进位乘法指令 (CLMUL)
  • Intel 融合乘加指令 (FMA)
  • VIA (Centaur) 安全指令
  • AMD XOP、FMA4 和CVT16 指令 (SSE5)
  • 提示 nop 指令的系统名称

如下所示:

I started to write a complete GNU as syntax from scratch.

The syntax file is available from vim.org: GNU as syntax for X86
As well as directly on GitHub: GNU as syntax for X86

In addition to the basic instructions it will recognize the following extended Intel / AMD instructions:

  • X86 common instruction set (8086 - 686)
  • Katmai Streaming SIMD instructions (SSE -- a.k.a. KNI, XMM, MMX2)
  • Introduced in Deschutes but necessary for SSE support
  • XSAVE group (AVX and extended state)
  • Generic memory operations
  • New MMX instructions introduced in Katmai
  • AMD Enhanced 3DNow! (Athlon) instructions
  • Willamette SSE2 Cacheability Instructions
  • Willamette MMX instructions (SSE2 SIMD Integer Instructions)
  • Willamette Streaming SIMD instructions (SSE2)
  • Prescott New Instructions (SSE3)
  • VMX Instructions
  • Extended Page Tables VMX instructions
  • Tejas New Instructions (SSSE3)
  • AMD SSE4A
  • New instructions in Barcelona
  • Penryn New Instructions (SSE4.1)
  • Nehalem New Instructions (SSE4.2)
  • AMD SSE5 instructions
  • Intel SMX
  • Geode (Cyrix) 3DNow! additions
  • Intel AES instructions
  • Intel AVX AES instructions
  • Intel AVX instructions
  • Intel Carry-Less Multiplication instructions (CLMUL)
  • Intel AVX Carry-Less Multiplication instructions (CLMUL)
  • Intel Fused Multiply-Add instructions (FMA)
  • VIA (Centaur) security instructions
  • AMD XOP, FMA4 and CVT16 instructions (SSE5)
  • Systematic names for the hinting nop instructions

Here is how it looks like:

alt text

友谊不毕业 2024-07-25 01:50:42

每当您打开 .asm 文件时,将此行放入您的 .vimrc 中即可使用 intel 语法进行设置:

autocmd BufNew,BufRead *.asm set ft=nasm

Putting this line in your .vimrc will set you up with the intel syntax whenever you open an .asm file :

autocmd BufNew,BufRead *.asm set ft=nasm
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文