Configure emacs to handle gas-style comments

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
kurmasz
Posts: 19
Joined: Tue Apr 04, 2017 2:37 pm

Configure emacs to handle gas-style comments

Post by kurmasz »

How do I configure emacs to "play nice" with assembly code to be compiled by the gnu assembler?

asm-mode assumes that the semi-colon is the only comment character. gas allows '#', '//', and '/* */'.

I figured out how to change the comment character to '#' using (setq asm-comment-char ?\#); but, indenting and line breaking still don't work right.
Specifically, if I type a long comment and press M-q, the lines break, but the additional lines are not prefixed by '#'. If I edit a comment and press M-q, the lines break, but the existing comment characters end up in the middle of lines.

Support for '//' and '/* */' would be nice, but I'll be happy if I can just get the '#' comments to re-balance when I edit them.

If there aren't any good solutions for emacs, can anybody suggest a better editor? (I did check out SASM, but it doesn't appear to "re-balance" comments. CLion only recently added syntax highlighting for assembly, and my University won't upgrade the image until the end of summer term.)
mallard
Member
Member
Posts: 280
Joined: Tue May 13, 2014 3:02 am
Location: Private, UK

Re: Configure emacs to handle gas-style comments

Post by mallard »

kurmasz wrote:CLion only recently added syntax highlighting for assembly, and my University won't upgrade the image until the end of summer term.
If you're a student, you can get a personal copy of CLion (and most of the rest of JetBrains' products) for free, so you don't have to wait for the university to upgrade.
Image
kurmasz
Posts: 19
Joined: Tue Apr 04, 2017 2:37 pm

Re: Configure emacs to handle gas-style comments

Post by kurmasz »

It turns out that even the current version of CLion doesn't handle multi-line comments very well.

Also, for what it's worth: My personal machine is a Mac, and the llvm linker doesn't appear to have sufficient flexibility to build an OS. The workflow will be much more convenient if I can use tools that I can build and run in Linux userspace.
goku420
Member
Member
Posts: 51
Joined: Wed Jul 10, 2013 9:11 am

Re: Configure emacs to handle gas-style comments

Post by goku420 »

Personally, I use vim. Works fine for intel syntax, but for GAS syntax you might have luck with https://github.com/Shirk/vim-gas (disclaimer: never tried it.)

And from what I heard development tools on Mac is weird, ranging from shipping an ancient version of GCC to Clang being symlinked to GCC. Though, if you are following the cross-compiler instructions it shouldn't be an issue.
Post Reply